Trouble with two WP queries (beginner) to pull two post types
Question
I’m running a page that currently pulls one post type of ‘news’ with a category of ‘dogs’.
However, I want to add another query that pulls everything from the ‘cat’ post type with no category parameter – just pulls every single cat post.
How can I adjust my code to add a second query to pull cat posts as well?
Code below:
$related_args = array(
'post_type' => 'news',
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'news-category',
'field' => 'slug',
'terms' => 'dogs',
'operator' => 'IN'
)
)
);
$related = new WP_Query( $related_args );
if( $related->have_posts() ) :
while ( $related->have_posts() ) : $related->the_post();
$cat = get_the_terms( $post->ID, ‘news-category’ );
0
php
3 years
2019-11-01T10:17:53-05:00
2019-11-01T10:17:53-05:00 0 Answers
70 views
0
Leave an answer