You can just simply create a custom query with WP_Query
. You just need to make sure if you are using a custom taxonomy or the build-in category. For reference, see: Is There a Difference Between Taxonomies and Categories?
Here is an example for custom taxonomies (this can also be used for build-in categories, just change 'taxonomy' => 'MY_CUSTOM_TAXONOMY',
to 'taxonomy' => 'category',
):
$args = array(
'post_type' => 'MY_CUSTOM_POST_TYPE',
'posts_per_page' => -1,
'orderby' => 'title',
'order' => 'DESC',
'tax_query' => array(
array(
'taxonomy' => 'MY_CUSTOM_TAXONOMY',
'field' => 'slug',
'terms' => 'THE_SLUG_FROM_MY_TERM',
),
),
);
$the_query = new WP_Query( $args );
// The Loop
echo '<ul>';
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '<li>' . get_the_title() . '</li>';
}
echo '</ul>';
/* Restore original Post Data */
wp_reset_postdata();
For a single term, you can also work directly with the query vars, so you can change your $args
to something like this
$args = array(
'post_type' => 'MY_CUSTOM_POST_TYPE',
'posts_per_page' => -1,
'orderby' => 'title',
'order' => 'DESC',
'MY_CUSTOM_TAXONOMY' => 'THE_SLUG_FROM_MY_TERM',
);
If you have a built-in category, change your $args
to the following
$args = array(
'post_type' => 'MY_CUSTOM_POST_TYPE',
'posts_per_page' => -1,
'orderby' => 'title',
'order' => 'DESC',
'cat' => 'THE_ID_OF_YOUR_CATEGORY',
);
For more useful parameters and the use there of, go and check out WP_Query
in the codex