MostRecent Plugin
This plugin returns the most recently added posts.
Download:
Download the latest version here or you can view the source.
Revision History:
| version 1.0 | Original Release |
| version 1.1 | Made into a generic plugin with support for filters. |
| version 1.2 | Setup to work as Sidebar Widget. |
| version 1.3 | Made plugin identifier functions universal for all plugins. |
| version 1.4 | Add flag for Widget to dis/en-able widget display on homepage. |
Installation:
- Copy the file rjs-mostrecent.php to the WordPress plugins directory on your server, (%WORDPRESS PATH%/wp-contents/plugins/).
- You will then need to activate the plugin from the WordPress administration plugins page.
- Use as a Sidebar Widget or modify your theme to include the desired data.
Usage:
-
MostRecent::get_links($iListSize, $iTitleSize, $iCatId)
- Provides a HTML List items (
<li>
) for recently added articles.
$iListSize
Optional, The number of results to list.
Default is 0$iTitleSize
Optional, The number of characters to return from each post for the title. Passing 0 will provide no trimming.
Default is 5$iCatId
Optional, The category id to return the list from. Passing -1 will return a list from all categories.
Default is -1 -
MostRecent::mostrecent($iListSize, $iTitleSize, $iCatId)
- Outputs the list from the MostRecent::get_links function.
$iListSize
Optional, The number of results to list.
Default is 0$iTitleSize
Optional, The number of characters to return from each post for the title. Passing 0 will provide no trimming.
Default is 5$iCatId
Optional, The category id to return the list from. Passing -1 will return a list from all categories.
Default is -1 -
This plugin implements three filter hooks which allow you to further customize what is returned. The hooks modify the FROM, WHERE, and ORDER BY SQL clauses. The filters are:
- rjs_mostrecent_from
- rjs_mostrecent_where
- rjs_mostrecent_order
This allows you to create your own plugins to modify the functionality of this plugin to meet the needs to your site better.
Examples:
- This example is the simplest call and returns the 5 most recently added posts.
<ul>
<?php MostRecent::write_links(); ?>
</ul>
- The example below would return a list of the 10 most recent post in category 3 with any titles longer than 30 characters trimmed to 27 in length and suffixed with “…”. The tooltip will still read the full title. The number of times the post has been viewed will be shown in brackets after the post title.
<ul>
<?php
if (is_callable('MostRecent','get_links')) {
MostRecent::write_links(10, 30, 3);
}
?>
</ul>
Rodney

Leave a comment