Support » Fixing WordPress » How do I get category.php to show children excerpts?

  • Hi all and good morning.

    I am using the following code to pull in a specific categories post

    but I wondered if anyone could offer a way to filter this just to show a specific category child.

    Can anyone offer any advice as to what I need to add to my code please?


Viewing 4 replies - 1 through 4 (of 4 total)
  • You’d have to use get_categories(‘child_of=’.get_query_var(‘cat’)) to get whatever child category then use that in your query.

    Thanks for that Michael,

    Is there anyone who could possibly show me how to implement in my code? I didn’t code this – my ‘ex’ did and he’s not around now!

    Thank you,

    Maybe it is simpler than I presented. Try about this:

    $cat_id = get_cat_ID('your child category name here');
      'cat' => $cat_id,
      'post_type' => 'post',
      'post_status' => 'publish',
      'posts_per_page' => -1,
      'caller_get_posts'=> 1
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      echo 'Child category excerpts';
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
        <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
    wp_reset_query();  // Restore global post data stomped by the_post().

    Sorry was away.

    Thank you so much. Will try this out tonight 🙂

    Thanks again.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How do I get category.php to show children excerpts?’ is closed to new replies.