• I have the following code in two themes:

    <?php
    foreach ($recentposts as $post) {
    if ($post->post_title == '')
    $post->post_title = sprintf(__('Post #%s'), $post->ID);
    echo "<li><a href='?p=$post->ID'>";
    the_title();
    echo '</a></li>';
    }
    ?>

    It works in one theme, but in the other, I get this error:

    Warning: Invalid argument supplied for foreach() in /home/myusername/public_html/wp-content/themes/minim8/sidebar.php on line 18

    The code is exactly the same for both. Whassup wif dat? Help appreciated and may result in good karma for you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Where is $recentposts set? It’s not a WP variable available to the templates, so a bit of (custom) code must be assigning something to it, possibly in the template of the theme where the code works.

    Thread Starter amulet

    (@amulet)

    Oh…after you explained that, it occurred to me to look for more code in the theme I copied that from…and I found it. It’s working now. Thanks. *blush!*

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Ok, I’m Stumped’ is closed to new replies.