coffee2code.com/wp-plugins/customizable-post-listings
Display Recent Posts, Recently Commented Posts, Recently Modified Posts, Random Posts, and other post listings using the post information of your choosing in an easily customizable manner. You can narrow post searches by specifying categories and/or authors, among other things.
- Download the file customizable-post-listings.zip and unzip it into your /wp-content/plugins/ directory.
-OR-
Copy and paste the the code ( customizable-post-listings.phps ) into a file called customizable-post-listings.php, and put that file into your /wp-content/plugins/ directory. Please ensure you do not introduce any spaces or other characters before the <?php or after the ?> - Optional: Change configuration options in the file to your liking. In-code comments should help you there.
- Activate the plugin from your WordPress admin ‘Plugins’ page.
- Include one or more of the templates defined below into a template file (most likely sidebar.php)
function c2c_get_recent_posts ($num_posts = 5, $format = "<li>%post_date%: %post_URL%</li>", $categories = '', $orderby = 'date', $order = 'DESC', $offset = 0, $date_format = 'm/d/Y', $authors = '', $include_passworded_posts = false)
function c2c_get_random_posts($num_posts = 5, $format = "<li>%post_date%: %post_URL%</li>", $categories = '', $order = 'DESC', $offset = 0, $date_format = 'm/d/Y', $authors = '', $include_passworded_posts = false)
function c2c_get_recently_commented ($num_posts = 5, $format = "<li>%comments_URL%<br />%last_comment_date%<br />%comments_fancy%</li>", $categories = '', $order = 'DESC', $offset = 0, $date_format = 'm/d/Y h:i a', $authors = '', $include_passworded_posts = false)
function c2c_get_recently_modified ($num_posts = 5, $format = "<li>%post_URL%<br />Updated: %post_modified%</li>", $categories = '', $order = 'DESC', $offset = 0, $date_format = 'm/d/Y', $authors = '', $include_passworded_posts = false)
- $num_posts : The number of posts to return; default is 5
- $format : A string that uses percent substitution tags to define the data you want displayed for each listing and how you want it displayed;set it to ” (two single-quotes) to return an array of the requested post objects without outputting anything.
- $categories : A space separated list of category IDs to match against; leave empty to consider posts from any category
- $order : The order with which the post listing should be sorted, either ‘ASC’ (for ascending) or ‘DESC’ (for descending); default is ‘DESC’
- $offset : The number of posts to skip; default is 0
- $date_format : Date format string, PHP-style, if different from the blog’s default date-format string
- $authors : A space separated list of author IDs to match against; leave empty to consider posts from any blog author
- $include_passworded_posts : A boolean value, either ‘true’ or ‘false’, indicating if passworded posts should be considered in the post search
The “Recent” listings on the sidebar of this site all use this plugin.
The simplest examples would be the following (for brevity’s sake, in the examples I’m going to specify 3 as the number of posts I want returned):
<ul> Recent Posts <?php c2c_get_recent_posts(3); ?> </ul>
Would output something like:
- Recent Posts
- 08/03/2004: Patch: Dealing with multiple <!–more–>
- 08/03/2004: Patch: Balancing pre-‘more’ tags
- 08/03/2004: Patch: Fixing balanceTags()
<ul>Recently Commented <?php c2c_get_recently_commented(3); ?> </ul>
Would output something like:
- Recently Commented
- Plugin: Category Image(s)
08/23/2004 10:25 am
14 Comments - Plugin: Get Custom Field Values
08/22/2004 04:35 pm
18 Comments - Plugin: wpPHPMailer
08/16/2004 01:15 am
11 Comments
<ul>Recently Updated <?php c2c_get_recently_modified(3); ?> </ul>
Would output something like:
- Recently Updated
- Plugin: Get Custom Field Values
Updated: 08/22/2004 - Plugin: wpPHPMailer
Updated: 08/17/2004 - Plugin: Hide or Cut Post Text
Updated: 08/17/2004
But what you may really want is to run the Recent Posts/Recently Commented Posts/Recently Updated Posts/Random Posts calls and customize the listing output. That’s where the percent substitution tags come into play. The second argument to each of the three functions above is the $format argument. $format is a string that represents how each post found by the function should be output. Any percent tags (as listed and defined above) will be replaced with the appropriate data.
So, let’s say you want a list of recent posts, to include the post author’s name linked to the archive of all of that author’s posts, plus a short excerpt of the post. And let’s say you only want posts from category ’34’. You’d do this:
<ul> <?php c2c_get_recent_posts(3, "<li>%post_date%: %post_URL%<br />by: %post_author_posts%<br />%post_excerpt_short%</li>", "34"); ?> </ul>
Which would output something like:
- 07/25/2004: Plugin: Hide or Cut Post Text
by: Scott
I’m pleased to announce the release… - 07/08/2004: Plugin: Random File
by: Scott
I just finished the final touches… - 07/08/2004: Plugin: Auto-hyperlink URLs
by: Scott
Finally, I managed to tackle a…
- 27 Sep 2004 : v1.2 —
- Added the ability to get random posts, and added the convenience function
c2c_get_random_posts()
to get them - Functions will now consider sticky posts (those in which ‘post_status’ gets set to ‘sticky’) in addition to published posts
- Changed license from BSD-new to MIT
- Added the ability to get random posts, and added the convenience function
- 05 Sep 2004 : v1.02 — Bugfix to immediately return if no posts match criteria
- 03 Sep 2004 : v1.01 — Bugfix for when
$authors
has more than one author - 27 Aug 2004 : v1.0 — Released to the public
Copyright (c) 2004 by Scott Reilly (aka coffee2code)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
My host, Dreamhost, has shut my website or my comments down twice because the query run by Customizable Post Listings was using too much server time. You can read about this in detail on my blog, if you want, but here’s a paragraph from a recent email they sent me:
Part of the problem is that my blog has an extremely active comments section, leading to a huge comments table.
Do you have any advice for me? I love the CPL plug-in, and would really like to continue using it – in fact, it’s essential for a blog like mine, in which conversations can continue for weeks on one blog comments thread. But, obviously, I can’t run it if it causes DreamHost to shut me down.
Thanks very much for your time, and for creating this plug in.
I need the same function as pierre as I wanted to use this to pull out featured posts from specific categories..
I was going to use a feature category and then pull out stories which were in both the featured category and the specific “sport” or “news” category.. to create the featured stories seciton..
If you want to use catg name like a tag you can do that:
find:
after add this:
find this:
"%post_title%", // Title for post
after add:
"%catg_title%", // Title for catg
After this little tweak you can use %catg_title% to display category name
Ex.:
c2c_get_recent_posts('',"%post_URL%%catg_title%%post_excerpt%", '1', 'date', 'DESC','1','','','', false); ?>
very Good , thanks For Your Plugin
I include the below code into my sidebar.php:
Recent Articles”;
c2c_get_recent_posts (7,”%post_URL%”,’’,’date’,
‘DESC’,1,’m/d/Y’);
echo “”;
} ?>
all I got is this error although i have already activated the plugin.
Parse error: parse error, unexpected ‘>’
Please help, Thanks a million
Is it possible to remove the bullet points on the side of each recent comment? (See site under comments header for example). I would like the comments to be flush to the left side. Any help would be greatly appreciated.
I’m having real trouble applying different styles to the date and post title. I want a list which shows date/post, date/post and have a template with a UL and a class to separate the styles. How can this be done?
Rhanks,
Sam.
I was looking for a plugin that lists all post headings on my home page and this plugin did the job for me. I just have a simple listing now, but would like to enhance it as below :
category1 :
post 1 heading by author
post 2 heading by author
…..
category 2:
….
Any help appreciated ..
I’d like to use this plugin but i can’t get it to work.
On my mainpage i would like 5 posts (with read more) and below it the headlines off 25 other posts.
Iam using the Blix theme and wp1.5.2
What i did:
– Download & Upload the plugin
– Activate it
– Pasted one of the funtions above into the index.php in the exerp(not the regular index.php but the one into the provided by blix, in the same folder as the side bar).
When i reload the page i get an error.
Could you please help me out?
This is the part of code i tried to use it into. Replaced it with the function of this plugin or added it, none worked:
” title=”Permalink”>
.png” height=”105″ width=”104″ hspace=”1″ vspace=”1″ align=”left” />
post_excerpt != “”)? the_excerpt() : the_content(); ?>
post_excerpt != “”) { ?>” class=”more”>Lees verder
om
‘,”); ?>
Figured it out 🙂
Is it also possible to add the time in front of the date?
Figured that out as well 🙂
It’s finished
www.nieuwszicht.com/
If Scott Reilly has some time, please contact me, i have some questions about the plugin codes, but it’s to difficult to ask here (without seeing the whole code for you)
I installed and activated the plugin. Nothing happens. The page looks the same as before. Any steps that I missed? I am familiar with php. Please help!
Oops! I meant ‘I am not familiar with php at all.’
great plugin
tnx 🙂
Hi Scott, hope you can help. I’m getting double spacing on this :
On my other theme it looked fine in single spacing, but now it doesnt look very good with my new theme, could you have a quick look at let me know what I might need to tweak?
Any tips would be greatly appreciated!!
thx!