Showing Custom Post Types filtered by category
I’m currently running the latest version of wordpress and have begun building a custom site starting off with Bones as a starter.
I’ve made a custom post type called artist and have enabled categories within it, there are two categories to filter. Resident and Guest.
I’m using the following code to display all the posts from the custom post type, but can’t get it to filter by category.
<?php $args = array( 'post_type' => 'artist', 'post_status' => 'publish', 'posts_per_page' => -1, ); echo '<ul id="onpagemenu">'; $posts = new WP_Query( $args ); while($posts->have_posts()) : $posts->the_post(); ?> <li><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('artist-thumb'); ?></a><br /> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endwhile; echo '</ul>'; wp_reset_query(); ?>
I’ve tried using something like
'category_name' => 'guest'in the
$args_guestarray, but it doesn’t change the outcome.
Does anybody have any suggestions on how I could get this to work?
Would be much appreciated.
- The topic ‘Showing Custom Post Types filtered by category’ is closed to new replies.