Home › Forums › Back End › Can't get WordPress custom post type posts by custom taxonomy › Reply To: Can't get WordPress custom post type posts by custom taxonomy
September 20, 2015 at 4:19 am
#208407
Participant
@rolandas What is $terms_as_text
? Where is it coming from? Does the category exist? Also, caller_get_posts
was replaced by ignore_sticky_posts
.
$args = array(
'post_type' => array('products'),
'category_name' => 'CATNAME',
'ignore_sticky_posts' => true,
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
?>
<!-- Do Magic Here -->
<?php the_title(); ?>
<?php
}
} else {
echo 'No Posts Found!';
}
wp_reset_postdata();
You might also try re-saving (resetting) Permalinks. On the Permalink Settings screen just select default, hit save, then change it back to post name, hit save… that’s it.
Hope that helps, Alen.