This WordPress plugin displays all posts from the last X days that contained posts. You can define the display template used to generate the list, choosing what data to display by inserting tags. Future-dated and private posts are hidden by default. This plugin can be called from a post or page, or directly from your theme’s template file, adding it to the sidebar, or wherever else you like.
Keep in mind, that this plugin does not list all the posts from the last X days, but rather the last X days that contained posts. For example, if you have it show the last 3 days, but you only have once post a month, it will list the latest 3 posts, because those were the latest 3 unique dates containing posts.
- Latest Release (For WordPress 2.3 through 2.8+)
- Download the above file, rename it from .txt to .php, and upload it to your plugins directory.
- Enable the plugin.
- Configure the plugin options (under DDLastXDays).
There are two ways you can use this plugin. In both usage methods, ‘X’ is the number of days you would like to display posts from.
1) In a post or page, insert the following line:
<!-- lastxdays X -->
2) In a template file, insert the following code:
<?php echo lastxdays_generate(X); ?>
Important: If you use the first method, make sure you add this using the html/code editor in WordPress, not the visual editor. In new versions of WordPress, just click the ‘html’ button above the edit box. If you use the visual editor it will not work, as the actual code you entered will be seen on the page, instead of being processed by the script.
- 08-26-08 Version 1.0 – First release.
Here are the options available on this plugin’s options page in the WordPress admin panel.
The default plugin options show a basic example of the template system, which should help make sense of it.
Hide private posts
If enabled, password-protected posts will be hidden.
Hide future-dated posts
If enabled, posts that have been dated in the future (to display on the site later) will be hidden.
Code added before list
This is the HTML that will be shown before the list generation.
This block of code is repeated for each post. You can also add the special tags, which will display the data about the post.
Tags: %POST_AUTHOR% %POST_DATE% %POST_TITLE% %POST_URL%
Code added after list
This is the HTML that will be shown after the list generation.
Date format for %POST_DATE%
This allows you to customize the date/time format for posts, when you are using this tag in your template. It uses the standard PHP date format.