Plugin for creating a list of recent blog posts on sidebar?
-
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
-
https://mtdewvirus.com/code/wordpress-plugins/
There are a few – a search for ‘recent posts’ at https://www.wp-plugins.net should turn a few more up.
This will do it too…
-
<?php wp_get_archives(‘type=postbypost&limit=10’); ?>
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
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.
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: https://mtdewvirus.com/code/wordpress-plugins/
Description: Returns a list of the most recent posts.
Version: 1.07
Author: Nick Momrik
Author URI: https://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;
}
?>
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>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….. ??
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… https://www.yellowswordfish.com
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
https://www.yellowswordfish.com/123/bush-doing-the-job-he-was-hired-to-do/
most definitely
Pete
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.
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:- The file was not in the proper directory. It needs to be in the [root]/wp-content/plugins/ directory.
- 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).
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)!
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 https://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 https://www.ads-software.com/support/topic/43494#post-245627however I’m definitely not a programmer.
curiously yours
Pete
No email received. Why not give me your address….
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!
- The topic ‘Plugin for creating a list of recent blog posts on sidebar?’ is closed to new replies.