AHP Sitewide Recent Posts plugin for WordPress MU

by Aziz Poonawalla on September 17, 2008

Building on the venerable Recent Posts plugin by Ron and Andrea, I have created an extended version that offers a lot more user control over output, including gravatar support. The basic features are:

  • excludes posts on main blog (blog ID = 1)
  • excludes first posts (Hello, world) on user blogs (post ID = 1)
  • option to show gravatar support (24px). Gravatar links to posts by user on their blog.
  • option to show post excerpt. User can specify excerpt length with extra argument. Option to capitalize 1st five words of excerpt for readability.
  • option to show post author name
  • option to show post date
  • option to show post comment count
  • all dispay options can be selectively toggled on or off using a single bitmask parameter, permitting very flexible and customizable usage (256 possible configurations!)
  • numerous other display and formatting options can be easily edited in source code using global vars

The argument list:

  • $how_many: how many recent posts are being displayed
  • $how_long: time frame to choose recent posts from (in days)
  • $optmask: bitmask for various display options (default: 255)
    • 1; // gravatar
    • 2; // date
    • 4; // author name
    • 8; // comment count
    • 16; // blog name
    • 32; // post name
    • 64; // post excerpt
    • 128; // excerpt capitalization
  • $exc_size: size of excerpt in words (default: 30)
  • $begin_wrap: start html code (default: <li class=”ahp_recent-posts”>)
  • $end_wrap: end html code to adapt to different themes (default: </li>)

To use the bitmask option, simply add the numeric codes for the display options you want together. For example, suppose you only want gravatar, post name, and date – then the bitmask would be 1+2+32 = 35. Using a bitmask in this way, you can turn on or off any combination of display options above, using only a single function argument.

The latest version (0.6) of this plugin is at WPMUDEV with a more complete description, installation instructions, screenshot, and sample function call. You can see also see the plugin in action at Talk Islam, under the sidebar section titled “Recent Journals”.

screenshot of AHP Recent Posts plugin for WPMU

screenshot of AHP Recent Posts plugin for WPMU

{ 108 comments… read them below or add one }

1 Roman February 11, 2010 at 8:19 am

Nice script, but for some reason on my page tekst is always on next line after avatar…

How to make this tekst showing next after avatar?? Same line with avatar, but on right side after avatar

Thank you!

2 Roman March 1, 2010 at 3:48 pm

Hi!

We using this plugin in MU…

witch tables do we have to create for DB (how to change db-config.php) if we are using multi-db plugin???
Or we don’t need to make any changes???

3 Jan March 13, 2010 at 6:41 am

We have the Problem from Roman to.
How work the plugin with multi-db?

4 Jishi Samuel April 20, 2010 at 4:51 am

Dear Aziz, This is a wonderful work done by you. Thanks a lot for sharing this. Is there any way i can get n number of recent posts from a particular blog on my main blog? and if possible n number of posts belonging to a particular category from a particular blog. I wish to have multiple blocks like this on the main blog home page. Please advise…

5 Dan April 30, 2010 at 8:35 am

Is there any way to strip the [caption] out of the excerpt?

Otherwise, the plugin works great. It’s the best plugin I’ve seen for site like mine that has blogs grouped together.

6 Rune June 18, 2010 at 6:50 am

Hello.
I’ve been looking around for the shortcode syntax to put this plugin to work on a wordpress site.
I’m wondering if I’m starting to go blind, cause I can’t seem to find it anywhere. :)

7 Aziz Poonawalla June 18, 2010 at 10:19 pm

Hello all,

I am about to shortly release v 0.8 which incorporates almost all teh changes and patches suggested above. Thank you to buzz_lightyear (19), IdaWebCo (25), Angelo (59), Ray (72), Alexandria (86) for your help in improving thi splugin! I will post the updated version shortly.

Note – the plugin does not show multiple posts per user partly by design; this way more prolific authors won’t dominate the output. But technically to implement that you’d need a meta-index of all posts which is not available in the standard WP database, though there is a (not free) plugin called Post Indexer available from WPMU that would let you do that. I prefer the way the plugin works as present and have no plans to introduce multiple posts; I might create an alternate version of the plugin later that uses the meta table from Posts Indexer, but thats lower priority for me right now.

Dave (38) – thats odd. it may be because the image is counted as part of the xcerpt. I will have to look at that.

Martin (47) – I think Alexandria (86) solved that problem – I’ve included it.

Dan (52) – pagination hadnt really ocurred to me, since I never imagined you’d use it for 300 post output :) The output is a simple list right now, so pagination might be prety hard. I’ll have to look into it,, but since thats a pretty extreme use case, i cant promise.

Mio (53) – you should be able to put the function call anywhere in your theme, not necessarily just the sidebar. You need to be able to edit your theme files, though.

Will (54) – I’m not exactly sure what you mean. Do you have an apostrophe in that blog name? the escaping might nbe the default behavior.

Nate (56) and Roman (65) – limiting to just one blog requires editing the SQL query, see comment by Darren #62 above.

werner (96) and seeley (97) – the part that strips htm is near the end where $thiscontent is defined and theer are calls to preg_replace and strip_tags. you can comment those lines out.

8 aziz July 5, 2010 at 4:37 pm

Hello folks,

I am going to be uploading the latest free version to wordpress.org shortly once my plugin is reviewed by them. This version will be free; however there will also be a paid version ($1) which will include a widget version for simpler installation. The widget version will become significantly more customizable over time than the free version, but core functionality will be the same. I will post links to the versions here once they are up and running.

stay tuned!

Leave a Comment

*
To prove you're a person (not a spam script), type the answer to the math equation shown in the picture. Click on the picture to hear an audio file of the equation.
Click to hear an audio file of the anti-spam equation

Previous post:

Next post: