Less talk, more code

The blog of Iskandar Soesman

WordPress MU Latest Posts

This plugin get all latest post truly ordered by date or by posting modified date. How this plugin works are: First, get all posts in last 30 days (by default). Then, all this post transformed as array data. We use posting date as key array. After that, we short this array data and ordered by the key (date).

By this method we can get truly latest post from entire blogs ordered by posting date or modified date.

Download

Feature

  • Get truly all latest post from entire blogs
  • You can either ordered by posting date or by posting modified date
  • You can defined how much words that you like to appear as teaser.
  • You can either make your teaser clean from any html tag or not.
  • Get author name
  • Get author url
  • Get total post comments

Parameters

  • $start_from: where array data start form.
  • $how_many (integer): how many array data are being to shorted.
  • $how_long_day (integer): time frame to choose recent posts from (in days).
  • $how_many_to_appear (integer): how many recent posts are being displayed.
  • how_many_words (integer): how many post's teaser are being displayed. Count by word. Default value are 50 words.
  • $clean_post (boolean): set true to remove any html tag within the post.
  • $short_by (string - post_date/post_modified): You can short the lattest post by positing date (post_date) or posting update (post_modified).

Return

  • ID
  • guid
  • post_title
  • post_content
  • author_url
  • author_name
  • post_date
  • post_time
  • comment_count

example 1

Default config

10 most recent entries over the past 30 days, displaying titles only

$latest_posts = wpmu_latest_post();
foreach($latest_posts as $latest_post){

echo '<p>'.$latest_post->post_title.'</p>';
}

example 2

5 most recent entries over the past 10 days, displaying titles, date, time, author, post url and first 30 words post as clean (without any html tag) teaser and order by most posting date.

$start_from = null;
$how_many = null;
$how_long_day = 10;
$how_many_to_appear = 5;
$how_many_words = 30;
$clean_post = null;
$short_by = 'post_date';

$latest_posts = wpmu_latest_post($start_from, $how_many, $how_long_day, $how_many_to_appear, $how_many_words, $clean_post, $short_by);
foreach($latest_posts as $latest_post){

echo '<p><a href="'.$latest_post->guid.'">'.$latest_post->post_title.'</a> - '.mysql2date(get_option('date_format'),$latest_post->post_date).' '.mysql2date(get_option('time_format'),$latest_post->post_date).' - by '.$latest_post->author_name.'</p>';
echo '<p>'.$latest_post->post_title.'</p>';
echo '<p>'.$latest_post->post_content.'</p>';
}