The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

not all posts in child categories showing up (3 posts)

  1. bridgemanusa
    Posted 6 years ago #

    Hi All:

    I was hoping someone out there in WP-genius land could shed some light on what I am doing wrong here. My "Blog" posts all exist under the parent category "Blog Posts" (although I have other parent categories that serving different purposes). I have created a page template with a custom query that calls my posts and paginates the results just fine if I am grabbing "all" posts in all categories (which I do not want to do). Ideally I would like to display all posts in the parent (Blog Posts) and all it's children but when I use the following I only get the first 3 posts (even though I know I have lots more):

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    'paged' => $paged,
    'category_name' => 'Blog Posts',
    'posts_per_page' => 5,
    $temp = $wp_query;
    $wp_query = null;
    $wp_query = new wp_query();
    <?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>`

    Any feedback would be greatly appreciated. Thanks in advance for looking!


  2. Michael
    Forum Moderator
    Posted 6 years ago #

    Show One Category by ID

    Display posts from only one category ID (and any children of that category):


    Show One Category by Name

    Display posts from only one category by name:

    query_posts('category_name=Staff Home');


    this is not totally clear, if calling the category by name is also displaying the children; try to use the cat ID.

  3. bridgemanusa
    Posted 6 years ago #

    Thanks for the reply alchymyth. I changed to cat id and it seems to be functioning normally now. All the child posts are being called.

Topic Closed

This topic has been closed to new replies.

About this Topic