Support » Themes and Templates » Recent Posts Arguments?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Play with this:

    <?php
    $posts=get_posts('showposts=5');
    if ($posts) {
    foreach($posts as $post) {
    setup_postdata($post);
    ?>
    <p>by <?php the_author(); ?><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
    <?php }
    }
    ?>

    Consider downloading and installing Otto’s php code widget and putting that code in one of those widgets:

    Please remember to support our plugin authors by clicking on the Donate button there.

    Hello MichaelH,

    First of all, thanks for assisting me with this issue. I followed your instructions, however unfortunately it didn’t work. You can see the results of the provided php code, after being placed inside Otto’s widget here: http://www.organic-tote-bags.com/blog/

    Any ideas..

    What’s this:
    PREVIOUS POSTS
    * WINTER DARK
    * BUDS

    Yes,
    * WINTER DARK
    * BUDS

    are the previous posts I would like to display, having the post date on their left-side. They are currently being displayed, using the “Recent Posts widget”.

    Beneath “Archives” you will see:
    by adminBUDS
    by adminBUDS

    These are the results of the php code you provided, using Otto’s Plugin.

    Try something like…

    <?php
    $posts=get_posts('showposts=5');
    if ($posts) {
    foreach($posts as $post) {
    setup_postdata($post);
    ?>
    <p><?php the_time('l, F jS, Y') ?> at <?php the_time() ?>
    <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
    <?php the_title(); ?></a>
    </p>
    <?php }
    }
    ?>

    Ok, we are getting close. Below is the modified code I used:

    <?php
    $posts=get_posts(‘showposts=5’);
    if ($posts) {
    foreach($posts as $post) {
    setup_postdata($post);
    ?>
    <p>“><?php the_time(‘j.m.y’); ?> / <?php the_title(); ?></p>
    <?php }
    }
    ?>

    But it only shows the oldest post “Buds” twice. It is not showing each post. How can I modify the above code to show each post and not the same post twice?

    You can view the results here: http://www.organic-tote-bags.com/blog/
    The results of the above code, appear beneath the heading “Test Code”

    I got it,

    Using the following:

    <?php while (have_posts()) : the_post(); ?>
    <p>“><?php the_time(‘j.m.y’); ?> / <?php the_title(); ?></p>
    <?php endwhile; ?>

    Wow, the Otto’s php code widget Plugin is great, I was able to use the same php that I used in the content area of the theme.

    Thanks for all your help t31os & MichaelH

    Regards,

    Welcome, i never tested the code… i just modified michaels….

    Glad you got there in the end though…. 😉

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Recent Posts Arguments?’ is closed to new replies.