Livog
Livog

Reputation: 195

Wordpress category list

Hi I am trying to display all post under an category. Looks like this

And that is how I category the post in wordpress when I make them, so they dont get mixed up. But still they do when i try to render them. All posts that is under G Is display under every game title (gears of war, geometry wars) I only want the post that have any posts under gears of war, they should be displayed under gears of war. Not under Geometry wars aswell.

Here is my code:

<?php
$cat_id = get_query_var('cat');
$catlist = get_categories('hide_empty=0&child_of=' . $cat_id);
$cat_child = get_field('frontend_name' , 'category_'  . get_query_var('cat' ));

foreach($catlist as $categories_item) {
    echo "<ol>";
    echo '<h3><a href="' . get_category_link( $categories_item->term_id ) . '" ' . '>' . $categories_item->description .'</a> </h3> ';
    query_posts("cat=$cat_id&post_per_page=9999");

if (have_posts()) : while (have_posts()) : the_post(); ?>
    <li><a href="<?php the_permalink();?>">
      <?php the_title(); ?>
   </a></li>
<?php endwhile; endif; ?>
<?php echo "</ol>"; ?>
<?php } ?>

Thanks!

Upvotes: 0

Views: 160

Answers (1)

The Maniac
The Maniac

Reputation: 2626

Change

query_posts("cat=$cat_id&post_per_page=9999");

To

query_posts("cat=" . $categories_item->term_id . "&post_per_page=9999");

Upvotes: 1

Related Questions