This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var WPAPI = require( 'wpapi' ); | |
var RSVP = require('rsvp'); | |
// Using the RSVP.hash utility for convenience and parallelism | |
RSVP.hash({ | |
categories: wp.categories().slug( 'it-services' ), | |
tags1: wp.tags().slug('hotel-name'), | |
tags2: wp.tags().slug('march-events') | |
}).then(function( results ) { | |
// Combine & map .slug() results into arrays of IDs by taxonomy | |
var tagIDs = results.tags1.concat( results.tags2 ) | |
.map(function( tag ) { return tag.id; }); | |
var categoryIDs = results.categories | |
.map(function( cat ) { return cat.id; }); | |
return wp.posts() | |
.tags( tags ) | |
.categories( categories ); | |
}).then(function( posts ) { | |
// These posts are all fiction, either magical realism or historical: | |
console.log( posts ); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment