0

Trying to query pages based on the category they are associated with. I am passing in the cat_ID, but it doesn't seem to be working. Always returns a single post with the title "Hello World" while there is an actual page with real title associated with this category.

// The Query
query_posts('cat='.$current);

// The Loop
while ( have_posts() ) : the_post();

    the_title();

endwhile;

// Reset Query
wp_reset_query();

1 Answer 1

0

It's because the default query is only querying for post_type post, you have to explicitly add page to get it to also query for pages:

$args = array(
    'cat' => $current,
    'post_type' => array( 'page', 'post' )
);
query_posts( $args );
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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