Viewing 9 replies - 1 through 9 (of 9 total)
  • I’d use the wp_get_archives() call. Check out this tutorial: http://codex.wordpress.org/Customizing_Your_Sidebar#Post_Lists

    Go to Presentation >> Theme Editor and click on “Sidebar.” Here’s the code that’ll do it:

    <h2 id="links">Recent Posts</h2>
    <ul>
    <?php get_archives('postbypost', '5', 'custom', '<li>', '</li>'); ?>
    </ul>

    Change that 5 to whatever number of posts you want to show up. Here’s the page from the Codex that talks about the possibilities:
    http://codex.wordpress.org/Template_Tags/get_archives

    this should work also :

    <?php
    function get_recent_posts($no_posts = 15, $before = '', $after = '<br>', $show_pass_post = false, $skip_posts = 0) {
    global $wpdb, $tableposts;
    $request = "SELECT ID, post_title FROM $tableposts WHERE post_status = 'publish' ";
    if(!$show_pass_post) { $request .= "AND post_password ='' "; }
    $request .= "ORDER BY post_date DESC LIMIT $skip_posts, $no_posts";
    $posts = $wpdb->get_results($request);
    $output = '';
    foreach ($posts as $post) {
    $post_title = stripslashes($post->post_title);
    $permalink = get_permalink($post->ID);
    $output .= $before . '' . $post_title . '' . $after;
    }
    echo $output;
    }
    ?>

    Yikes! That’s bulky code!

    Why so lengthy? I’m doing this same thing in *way* less code. Just curious why that’s so complex.

    I agree with tsguitar; seems excessively complex. If there’s a WP tag for it, why use a paragraph of code?

    ok was just trying to help with what i have … 🙂

    And that’s fine. That’s not why you got that response. Thank you for posting another solution to this person’s problem. Someone else will surely find it useful in the future.

    I’m just really curious why it’s so long. Is there a reason?

    no idea 🙂 dident even bother my self to understand it 🙂

    i found it today on a new wordpress theme and it was working gr8 so i just said i’ll post it …

    Ah. Well, that’s a lot more code than needed to make this happen. If you want to make your site faster and put less stress on your database, take a look at the code I suggested. If you want…

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Recents posts in sidebar’ is closed to new replies.