Template tags error: recent posts (4 posts)

  1. indecipher
    Posted 9 years ago #

    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; ?>

  2. moshu
    Posted 9 years ago #

    Maybe this "mini-Loop" of yours is interfering with the main Loop?
    Why not use a recent_posts plugin?

  3. indecipher
    Posted 9 years ago #

    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.

  4. moshu
    Posted 9 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic