I've created a function to call in a page template, inside of which is the following query:
$custom_news = new WP_Query(array( 'post_type' => array('post', 'resource', 'job'), 'posts_per_page' => 5, 'tag' => 'justice', 'orderby' => 'post_date', 'order' => 'DESC', ) );
The problem is that the 'resource' and 'job' CPTs are not being included in the query, even though they have been registered with
'taxonomies' => 'post_tag'. Here is the generated SQL:
[request] => SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (13) ) AND wp_posts.post_type IN (‘post’, ‘portfolio’) AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_author = 1 AND wp_posts.post_status = ‘private’) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 5
The only CPTs included in the query are 'post' and 'portfolio' (which is a CPT that comes with the theme I'm using).
However, if I remove the
'tag' => 'justice' argument, the post type argument is "seen" by the query, and the following SQL is generated:
[request] => SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_type IN (‘post’, ‘resource’, ‘job’) AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_author = 1 AND wp_posts.post_status = ‘private’) ORDER BY wp_posts.post_date DESC LIMIT 0, 5
I should also mention that I've tried it with the
tax_query arguments to no avail.
Could anyone illuminate why this might be? It could be I'm missing something very basic, and if so, forgive me.