Currently 18:31:28 GMT

(Login | Register)

Owner: Andrea_r

Type: WPMU Plugin

Created: 2007-02-04 20:32:45

Last Modified: 2007-02-04 20:33:57


ah-recent-posts-mu.php (3432 download(s))

Code used to display the last ten posts across the system. Use this by pasting the following in a theme file wherever you want it to show:



Posted 2007-02-07 00:12:35 by wazimm.

I place the code in home.php and nothing happens


Posted 2007-02-07 17:52:00 by andrea_r.

The code listed at the top of the plugin file? Because it didn't show up here. Did you put this in the mu-plugins folder? Are the blogs on the system marked as public? Do you have a spot I can go look, because you didn't give me much to go on.


Posted 2007-02-09 14:15:34 by skcsknathan001.

I see two problems 1) If no updates within one day, then the list is empty 2) guid does NOT always correct http://mu.wordpress.org/forums/topic.php?id=2492&replies=5


Posted 2007-04-13 13:11:19 by slaqua.

I have updated the plugin... it now allows to define number of posts to be displayed, date range for what is "recent" and the option to switch the display between title+blog and title only Code here: /* Plugin Name: WordPress MU Recent Posts Plugin URI: http://atypicalhomeschool.net/wordpress-plugins/ Description: Retrieves a list of the most recent posts in a WordPress MU installation. Based on (Andrea - fill this in) Author: Ron Rennick Author URI: http://atypicalhomeschool.net/ */ /* Version: 0.31 Update Author: Sven Laqua Update Author URI: http://www.sl-works.de/ */ /* Parameter explanations $how_many: how many recent posts are being displayed $how_long: time frame to choose recent posts from (in days) $titleOnly: true (only title of post is displayed) OR false (title of post and name of blog are displayed) Sample call: ah_recent_posts_mu(5,30,true); >> 5 most recent entries over the past 30 days, displaying titles only */ function ah_recent_posts_mu($how_many,$how_long,$titleOnly) { global $wpdb; $counter = 0; // get a list of blogs in order of most recent update $blogs = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs WHERE last_updated >= DATE_SUB(CURRENT_DATE(), INTERVAL $how_long DAY) ORDER BY last_updated DESC"); if ($blogs) { foreach ($blogs as $blog) { // we need _posts and _options tables for this to work $blogOptionsTable = "wp_".$blog."_options"; $blogPostsTable = "wp_".$blog."_posts"; $options = $wpdb->get_results("SELECT option_value FROM $blogOptionsTable WHERE option_name IN ('siteurl','blogname') ORDER BY option_name DESC"); // we fetch the title and link for the latest post $thispost = $wpdb->get_results("SELECT post_title, guid FROM $blogPostsTable WHERE post_status = 'publish' AND post_type = 'post' AND post_date >= DATE_SUB(CURRENT_DATE(), INTERVAL $how_long DAY) ORDER BY id DESC LIMIT 0,1"); // if it is found put it to the output if($thispost) { if ($titleOnly == false) { echo '

"; $counter++; } else { echo ''; $counter++; } } // don't go over the limit if($counter >= $how_many) { break; } } } }


Posted 2007-04-13 13:12:29 by slaqua.

Well, that did not work... If anybody lets me know how, I can upload the updated version on here somewhere....


Posted 2007-04-13 16:23:47 by slaqua.

Well, that did not work... If anybody lets me know how, I can upload the updated version on here somewhere....


Posted 2007-04-20 22:23:26 by Jeck Pixelbrei.

I don't know how this system here works but am very interested in the updated version. Could maybe make it available somewhere else?


Posted 2007-04-21 22:27:50 by slaqua.

I have uploaded it here: http://wpmudev.org/project/Most-recent-posts---updated


Posted 2007-06-22 18:18:38 by klezmer41.

I wrote some code to pull down every post in a MU installation, but I don't want to reinvent the wheel (maybe I already did). Let me know what you think: scotthildebrand.com/code


Posted 2007-06-22 18:22:50 by klezmer41.

I wrote some code to pull down every post in a MU installation, but I don't want to reinvent the wheel (maybe I already did). Let me know what you think: scotthildebrand.com/code


Posted 2007-06-22 18:32:16 by klezmer41.

I didn't know that WP had all this db functionality built in like what slaqua did... $blogs = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs WHERE last_updated >= DATE_SUB(CURRENT_DATE(), INTERVAL $how_long DAY) ORDER BY last_updated DESC"); That would probably make things easier, but whatever it works. Right now my code constructs URLs differently based on whether the post is a 'post' or a 'page,' but doesn't check to make sure it's 'published.' And I'm not including post content in this version, but that would be easy to add in.


Posted 2007-10-18 14:45:17 by DragonFlyEye.

I made a bunch of tweaks to this plugin and I'd like to contribute them here. How would I do that? The tweaks are the following: 1. Maybe its just my system, but the original function was ah-most-recent-mu(), and to my great surprise, WP did.not.like the "-" at all. I switched them to "_". 2. This version is a Widget 3. Allows the user to select how many posts to display and the interval (number of days, weeks, months or years) to use in determining what is "recent."


Posted 2007-10-18 14:46:08 by DragonFlyEye.

PS: the non-formatted comments here kinda blow. }8{D>


Posted 2007-10-27 02:10:45 by ovizii.

can you please provide a download link for the last modified version?


Posted 2008-02-16 01:50:04 by gmorehou.

I've improved the plugin so that it doesn't show nonpublic posts, nor spam/archived/mature/deleted blog posts, and so that actual permalinks are used (ie the guid is NOT used, but rather the proper function in wpmu-functions.php). Please see http://wiki.evernex.com/index.php?title=Wordpress_MU_sitewide_recent_posts_plugin


Posted 2008-02-29 03:16:00 by horrorshow.

thanks for the plugin. Please correct me if I am wrong, but this grabs the 1 latest post per blog? Is there an alternative where it grabs 10 latest post regardless of which blog it belongs to?


Posted 2008-02-29 19:11:18 by horrorshow.

thanks for the plugin. Please correct me if I am wrong, but this grabs the 1 latest post per blog? Is there an alternative where it grabs 10 latest post regardless of which blog it belongs to?


You must be registered and logged in to post comments. Not registered? Click here to get your free account!