node-wpapi icon indicating copy to clipboard operation
node-wpapi copied to clipboard

create post's taxonomies by slug not ID

Open kauaicreative opened this issue 3 years ago • 1 comments

Is it possible to create post's taxonomies by slug not ID.

Like this:

wp.school().create({
   title: 'title',
   state: ['ca', 'az']
})

Not this way:

wp.school().create({
   title: 'title',
   state: [22, 23]
})

kauaicreative avatar Apr 26 '21 22:04 kauaicreative

@kauaicreative I don't think you can do what you are asking in a single request, however you can use the term slug to find the term ID and then pass it into the create request.

Check out this section of the README which explains the usage of .slug():

To find the ID of a tag or category for which the slug is known, you can query the associated collection with .slug() and use the ID of the returned object in a two-step process...

kevinwhoffman avatar May 11 '21 03:05 kevinwhoffman