6

I am trying to select all the posts from certain post type and term in custom taxonomy, but what ever I try gets me just the list of all the posts in certain post type

wp post list --post_type=custom-type --fields=post_name,ID

This returns all posts in cpt custom-type, but say I want to list only posts in term that has id 49, I tried

wp post list --post_type=custom-type --taxonomy=custom-tax --terms=49 --fields=post_name,ID

But again I got everything. In the documentation it says that the arguments are passed to WP_Query, but how do I do a tax_query?

EDIT:

Ok so wp term list custom-tax will return the correct list of terms in the taxonomy. So I need to see how to use this to my advantage...

1 Answer 1

8

Assume we have a custom post type movie (slug) and a custom taxonomy cast (slug).

1) To find all movies starring Emily Watson, stored with the term slug emily-watson, we can do:

wp post list --post_type=movie --cast=emily-watson

to list all her movies.

2) To find all movies featuring Elizabeth Taylor or Richard Burton , stored with the term slugs elizabeth-taylor and richard-burton, we can do:

wp post list --post_type=movie --cast=elizabeth-taylor,richard-burton

We should at least get Cleopatra (1963) ;-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.