WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. bridgemanusa
    Member
    Posted 3 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):

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

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

    Eric

  2. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    Show One Category by ID

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

    query_posts('cat=4');

    Show One Category by Name

    Display posts from only one category by name:

    query_posts('category_name=Staff Home');

    from
    http://codex.wordpress.org/Function_Reference/query_posts#Category_Parameters

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

  3. bridgemanusa
    Member
    Posted 3 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

Tags