WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Ok, I've been frustrated about this one:

I've got a category page with the Title + Description of the title. Under it I would like to show all the (custom post type, 'blog') posts related with this category and under it related posts of custom post type 'apps'. When applying the following code it only generates all 'blog' topics with all categories (instead of only the current i'm viewing).

I have this for now:

<?php query_posts( array( 'numberposts' => 5, 'category' => 9, 'post_type' => 'blog' ) ); if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

When using:

 <?php if (have_posts()) : ?>
   <?php while (have_posts()) : the_post(); ?>

Does anyone know how I can only show all related posts of this category with custom post type 'blog' ?

share|improve this question
up vote 1 down vote accepted

It is 'cat', not 'category'.

query_posts( array( 'numberposts' => 5, 'cat' => 9, 'post_type' => 'blog' ) );

Also, be aware the query_posts alters the main page query. Unless you specifically intend to do that, and need to do it, use get_posts or make a new WP_Query object. And if you do have to use query_posts reset the query when you are done-- wp_reset_query. This is all right there in the Codex.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.