WordPress.org

Ready to get started?Download WordPress

Forums

Plugin for creating a list of recent blog posts on sidebar? (17 posts)

  1. addcoach
    Member
    Posted 8 years ago #

    Is there a way to get a list of recent blog posts on sidebar?

    Maybe a plugin or some other way to do it? i.e., list your 10 most recent posts on the sidebar just by title with hot links?

    thanks

    Pete

  2. Mark (podz)
    Support Maven
    Posted 8 years ago #

    http://mtdewvirus.com/code/wordpress-plugins/

    There are a few - a search for 'recent posts' at http://www.wp-plugins.net should turn a few more up.

  3. YellowSwordfish
    Member
    Posted 8 years ago #

    This will do it too...

      <?php wp_get_archives('type=postbypost&limit=10'); ?>
  4. addcoach
    Member
    Posted 8 years ago #

    thanks for the tips Podz but having a lot of trouble configuring the plugins.

    YellowSwordfish it worked great much less effort. But right now there's no space between the entries. They're stacked so close together you can't tell them apart.

    Is there a way of adding a space between each item?

    Also typepad has this function built in stock. Is there any chance wordpress might add this a basic feature not a plug in? I'm sure there are quite a few wordpress bloggers that might use something like this to show their readers previous posts, so they go deeper into the blog. Great way to show potential readers what sort of stuff you're doing in an easy to scan way.

    Pete

    thanks

    Pete

  5. billh
    Member
    Posted 8 years ago #

    I use Nick's plugin (mtdewvirus) that podz mentions. It's pretty simple. Just download and activate the plugin, then put this line in the sidebar code:
    <?php get_recent_posts(7,'<li>','</li>',true,0,false); ?>

    The "7" means show the most recent seven posts, the list item tags (li and /li) open and close each post in a list, "true" means to show password protected posts, "0" means to skip no posts, and "false" means to not show excerpts. Of course, you can use any of the parameters you wish.

  6. addcoach
    Member
    Posted 8 years ago #

    HI Bill,

    I tried that

    I just changed 7 to 10 as shown below which i posted in my sidebar

    <?php get_recent_posts(7,'<li>','</li>',true,0,false); ?>

    and got my whole blog turning blue ie in the text are and this error message

    Fatal error: Call to undefined function: get_recent_posts() in (it list's my directory then continues wp-content/themes/northern-web-coders/sidebar.php on line 148

    Here is a copy of the plug in i got. I choose it from the trunk file, is that the right one? is there any other code i need?

    thx

    Pete


    <?php
    /*
    Plugin Name: Recent Posts
    Plugin URI: http://mtdewvirus.com/code/wordpress-plugins/
    Description: Returns a list of the most recent posts.
    Version: 1.07
    Author: Nick Momrik
    Author URI: http://mtdewvirus.com/
    */
    function mdv_recent_posts($no_posts = 5, $before = '<li>', $after = '</li>', $hide_pass_post = true, $skip_posts = 0, $show_excerpts = false) {
    global $wpdb;
    $time_difference = get_settings('gmt_offset');
    $now = gmdate("Y-m-d H:i:s",time());
    $request = "SELECT ID, post_title, post_excerpt FROM $wpdb->posts WHERE post_status = 'publish' ";
    if($hide_pass_post) $request .= "AND post_password ='' ";
    $request .= "AND post_date_gmt < '$now' ORDER BY post_date DESC LIMIT $skip_posts, $no_posts";
    $posts = $wpdb->get_results($request);
    $output = '';
    if($posts) {
    foreach ($posts as $post) {
    $post_title = stripslashes($post->post_title);
    $permalink = get_permalink($post->ID);
    $output .= $before . '<a href="' . $permalink . '" rel="bookmark" title="Permanent Link: ' . htmlspecialchars($post_title, ENT_COMPAT) . '">' . htmlspecialchars($post_title) . '</a>';
    if($show_excerpts) {
    $post_excerpt = stripslashes($post->post_excerpt);
    $output.= '' . $post_excerpt;
    }
    $output .= $after;
    }
    } else {
    $output .= $before . "None found" . $after;
    }
    echo $output;
    }
    ?>

  7. -P-
    Member
    Posted 8 years ago #

    YellowSwordfish it worked great much less effort. But right now there's no space between the entries. They're stacked so close together you can't tell them apart.

    Is there a way of adding a space between each item?

    Use <li> and/or <ul> -tags just like normally.

    For example
    <ul>
    <li><?php wp_get_archives('type=postbypost&limit=10'); ?></li>
    </ul>

  8. YellowSwordfish
    Member
    Posted 8 years ago #

    Best bet is to put a little padding between them in your CSS.
    If you give the

      a class name like:

      <ul class="recentposts">

      then define a

      .recentposts li {padding-bottom: 10px;}

      in your CSS style sheet that shoud do the trick. I think..... :)

  9. YellowSwordfish
    Member
    Posted 8 years ago #

    Actually - I use this call on my sidebar and put a small rule between them which I quite like. Take a look if you wish... http://www.yellowswordfish.com

  10. addcoach
    Member
    Posted 8 years ago #

    Hi YellowSwordfish,

    tried it but it didn't work. still no space between the posts. or even space between the recent post section title and the content.

    i put it under the p.credit at the bottom of the css. is there another place it should be?

    I posted it exactly like this, is there something else I need to add?

    '<ul class="Recent Posts">
    .recentposts li {padding-bottom: 10px;}'

    it seem different from the rest of my css stuff, it looks like this below

    '#content div.post div.storycontent blockquote
    {
    background: #CCFFFF;
    border: 1px solid #CCFFFF;
    border-left: 2px solid #CCFFFF;
    font-family: Georgia, Times New Roman, serif;
    font-size: 11px;
    margin-left: 20px;
    padding: 4px 4px 4px 7px;
    width: 80%;
    }'

    any suggestions?

    oh good post

    http://www.yellowswordfish.com/123/bush-doing-the-job-he-was-hired-to-do/

    most definitely

    Pete

  11. YellowSwordfish
    Member
    Posted 8 years ago #

    Sorry addcoach - been out of the loop most of the last week. Have you solved this yet? If not, email me (andy at yellowswordfish dot com) and I'll email you back the html and css I am using for that part.

  12. billh
    Member
    Posted 8 years ago #

    Yellowswordfish, cool site. If you get an error like the one you describe (Fatal error: Call to undefined function: get_recent_posts()) then the most common problems are:

    1. The file was not in the proper directory. It needs to be in the [root]/wp-content/plugins/ directory.
    2. The plugin was not activated. To activate it, simply go to the "Plugins" section of the Admin panel and then locate the "Recent Posts" plugin and activate it. If it isn't in the list, it isn't in the proper directory. (check #1).
  13. YellowSwordfish
    Member
    Posted 8 years ago #

    Hi billh - thanks for the kind comment.
    Actually - reading back over the thread, if you look at the code segment addcoach posted, seems to me he used:
    mdv_recent_posts()
    insrtead of
    get_recent_posts()
    which would explain the call to undefined function. Maybe...

    He didn't come back to me on the CSS and HTML which he seems to have got mixed up (HTML in the CSS file)!

  14. addcoach
    Member
    Posted 8 years ago #

    Hi Bill,

    thanks for replying but I did have the file in the right directory and it was activated.

    Yellowfish I did send you an email, did you not get it?

    in terms of this"seems to me he used:
    mdv_recent_posts()
    insrtead of
    get_recent_posts()"

    I didn't change anything here, that's the code that the developer used

    see http://dev.wp-plugins.org/file/recent-posts/trunk/recent-posts.php
    I'm not sure what you mean i got the css and html mixed up, I put them in exactly like you said in this post http://wordpress.org/support/topic/43494#post-245627

    however I'm definitely not a programmer.

    curiously yours

    Pete

  15. YellowSwordfish
    Member
    Posted 8 years ago #

    No email received. Why not give me your address....

  16. kimchihead
    Member
    Posted 8 years ago #

    YellowSwordfish: I really like your solution-

    <?php wp_get_archives('type=postbypost&limit=10'); ?>

    Is there any way to include the date using this piece of code?

    Thanks!

  17. billh
    Member
    Posted 8 years ago #

    YellowSwordfish: Thanks for the input. I was using an older version of the plugin that had the function name get_recent_posts() ; I just updated my plugin and found that Nick changed the function name to mdv_recent_posts(). That is probably why addcoach was having the problems. (slaps forehead with palm in disgust!)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags