Support » Themes and Templates » Template tags error: recent posts

  • Hi. I’ve been having a problem with some template tags. What I’m trying to do is show the 5 most recent posts in descending order by date and with permalinks. Oddly enough, I got this to work just fine- no errors or anything. I achieved it just by tweaking the code I got from the WordPress Codex pages on this subject. But for some reason (quite unapparent to me), none of the main page text is loading at all. The template displays just fine, and the footer, header, navigational bar… but the text just isn’t there. Can someone help? Maybe you’ll be able to spot what’s causing the problem. Here is my code:

    <?php $posts = get_posts('numberposts=5&offset=0&orderby=post_date&order=DESC');
    foreach ($posts as $post) : start_wp(); ?>

    <li><?php the_date(); echo ""; ?><a>"><?php the_title(); ?></a></li>
    <?php endforeach; ?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • Maybe this “mini-Loop” of yours is interfering with the main Loop?
    Why not use a recent_posts plugin?

    Thanks for your help- the recent_posts plugin works, if not exactly in the way that I want, but at least it works! That’s certainly an improvement. Anybody know a way to get it to show the post date, though? I’ve been tinkering and haven’t found any way to achieve that yet.

    There are at least 3-4 recent posts plugins – so, unless you let us know which one we are talking about…

    The one I am using lets me display the date; see left top.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Template tags error: recent posts’ is closed to new replies.