Support » Fixing WordPress » Show category once in a loop

Viewing 8 replies - 1 through 8 (of 8 total)
  • Moderator keesiemeijer



    with a counter :

    Thank for you answer soo much!
    But, it’s doesnt work for me( Showing same. Can you explain how its works?

    what will be the output? can you give a demo?


    Click to first column (Меню еды)
    How you can see, the expandable box name is child cat name, and i want tp show that once.

    try once

    <?php  $cats = get_the_category('cat_name=food_menu');
           foreach($cats as $c):?>
                                    	<div class="item"><span><?php echo $c->cat_name;?></span></div>
    <?php query_posts('category_name=' . $c->cat_name);
    				if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
                                            <ul style="display:none">
                                              	<div class="left_block">
                                                    <div class="name"><span><?php the_title (); ?></span></div>
                                                    <div class="text"><span><?php the_content (); ?></span></div>
                                               	<div class="price"><span><?php the_excerpt (); ?></span></div>
                                                    <div class="cb"> </div>
    								 <?php endwhile; wp_reset_query ();?>
    <div class="cb"> </div>
    <?php endforeach;?>


    Thank you for try, but doesn’t work at all( Box just disappear. Can you offer in another way? and pls don’t forget that i’m using child cat name in expand box.

    replace $cats = get_the_category('cat_name=food_menu');


    $cats = get_categories('child_of=3&hide_empty=0');

    OK. Now! It’s working, but, the posts are showing by one too (( I need to show once only cat names.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Show category once in a loop’ is closed to new replies.