• britanik

    (@britanik)


    <?php
    $all_cats = wp_list_categories('hide_empty=0&amp;title_li=&amp;child_of=4');
    foreach( $all_cats as $cat ) :
    ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php
    endforeach;
    ?>

    What I’m trying to do is to show ALL needed categories with IT’S posts …
    But I’m stuck with this code … it shows all cats that i need, but in the end of it I see an Error:

    Warning: Invalid argument supplied for foreach() in K:\home\test1.ru\www\wp-content\themes\artel\header.php on line 78

    Can somebody give me a right solution for this ?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter britanik

    (@britanik)

    That is what im trying to do … i think it’s clear:

    <?php
    $all_cats = wp_list_categories('hide_empty=0&amp;title_li=&amp;child_of=4');
    foreach( $all_cats as $cat ) :
    ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    <ul>
       <?php
           $stringGetPosts = "numberposts=0&amp;category='".the_ID()."'4&amp;orderby=menu_order&amp;order=ASC";
           get_posts($stringGetPosts);
       ?>
    </ul>
    </li>
    <?php
    endforeach;
    ?>
    t31os

    (@t31os)

    Try adding…

    &amp;echo=0 to the list cats function call.

    It outputs the result by default, so you need to stop that firstly….

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Trying to show all posts in category -> Invalid argument supplied for foreach()’ is closed to new replies.