Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Child categories with list of posts WordPress

  • SOLVED

Right now this page is showing all of the posts from the parent category first. I want to remove the first part that displays all of the content, and to just show the child categories with a list of each lesson. I just need help with the top part.

http://www.talkaboutthework.com/lessons

Has to do with this loop:


<div class="right-opt">
<!-- right-opt-->
<?php $childs = get_categories('child_of='.$parent->cat_ID);
foreach($childs as $child){
?>
<ul>
<li><?php echo $child->name; ?></li>
<?php query_posts('cat='.$child->cat_ID.'&posts_per_page=-1&orderby=title&order=ASC'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post();?>
<li>
<a href="<?php the_permalink(); ?>">- <?php the_title(); ?></a>
</li>
<?php endwhile; endif; ?>
<?php wp_reset_query(); ?>

</ul>
<?php } ?>
</div><!-- end right-->

Answers (1)

2011-10-20

Luis Cordova answers:

so is the problem that you are unable to fetch the posts?

I think it is because you are using query_posts when you need to use WP_Query



<div class="right-opt">

<!-- right-opt-->

<?php $childs = get_categories('child_of='.$parent->cat_ID);

foreach($childs as $child){

?>

<ul>

<li><?php echo $child->name; ?></li>

---> <?php query_posts('cat='.$child->cat_ID.'&posts_per_page=-1&orderby=title&order=ASC'); ?>

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

<li>

<a href="<?php the_permalink(); ?>">- <?php the_title(); ?></a>

</li>

<?php endwhile; endif; ?>

<?php wp_reset_query(); ?>



</ul>

<?php } ?>

</div><!-- end right-->


Louis Gubitosi comments:

See where it says "Part 01: It's Okay To Be The Boss - Be A Great One!" on http://www.talkaboutthework.com/lessons

I want to get rid of everything above that (the parent category and all of the posts listed)


Luis Cordova comments:

I only see

Our Videos

It's Okay to Be the Boss


Louis Gubitosi comments:

You don't see the list underneath??