Welcome to Dagon Design. In addition to free scripts, WordPress plugins, and articles, we offer a variety of services including custom theme design, plugin creation, and PHP scripting. Contact me for more information.

Version 1.92   Updated Tuesday, July 7th, 2009 at 6:18pm

Latest Post from each Category plugin for WordPress

This plugin displays a list of the latest post from each category of your WordPress installation. It can be added to a post or page, or used directly in a template file. In the plugin’s options page you can choose the sort order, show or hide the dates, select the date formatting, show the first X characters of the content, display a link to the comments, and show comment counts, as well as other options.

Download

  If you have found this page useful, please consider donating. Thanks!

Installing

  • 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 DDLatestFromEach).

Using

There are two ways you can use this plugin.

1) In a post or page, insert the following line:

<!-- ddlastfromeach -->

2) In a template file, insert the following code:

<?php echo dd_last_from_each(); ?>

Change Log

  • 07-07-09 Version 1.92 – Slight change to the way the list is displayed.
  • 07-06-09 Version 1.91 – You can now choose how many posts per category to display.
  • 02-19-09 Version 1.9 – Added option to use only selected categories.
  • 08-14-08 Version 1.8 – Tested with WordPress 2.6. Now uses WordPress function for determining date/time to show up to date posts. Added option to exclude categories.
  • 09-27-07 Version 1.7 – Updated to support WordPress 2.3. Added ‘Load Default Options’ button.
  • 05-31-07 Version 1.6 – Better support for international date formatting
  • 05-16-07 Version 1.5 – Updated for WordPress 2.2
  • 02-20-07 Version 1.4 – Updated for WordPress 2.1 (new pages were showing up in the default category)
  • 08-09-06 Version 1.3 – Added options to show comment links and counts. Also added an optional limit to the number of links shown, and a few other fixes.
  • 06-03-06 Version 1.2 – Added an option to turn category names into links. A bug was also fixed where extra slashes were being shown in the header text.
  • 05-31-06 Version 1.1 – You can now choose the sort order of the output, hide password-protected posts, and show the first X characters of the content after each post. A few other fixes have been made as well.
  • 05-30-06 Version 1.0 – First release.

Demo

Here you can see the plugin in action:

Latest Post From Each Category

Options

Here are the options available in this plugin’s options page in the WordPress admin panel.

Header text

This is shown above the list of posts.

Sort order

You can choose to have the data sorted by category or date. You also have the option of ascending or descending on both.

Show link to comments

When enabled, this will add a link to the comments for each post listed.

Include number of comments

This option only applies if Show link to comments is enabled. It adds the number of comments to the comment link.

Include link for posts with no comments

This option only applies if Show link to comments is enabled. It allows you to include or hide the comment link for posts with no comments.

Turn category names into links

Enabling this option will turn category names into links to the categories.

Hide password-protected posts

This prevents password-protected posts from showing up.

Show date after listed posts

This will show the post date after each post in the list.

Date format

If you are showing the date after posts, this will allow you to configure the date format (using the standard PHP date() format)

Show first X characters of posts

This allows you to show a preview of the content under each post in the list.

Number of characters to show

This lets you specify how many characters of the content will be shown, assuming you have the previous option enabled.

Limit list to X categories

This allows you to set a limit on the number of categories that will be shown in the list. Set to 0 for no limit.

Excluded category IDs

This is a comma-separated list of category ID’s you want excluded from the list.

Included category IDs

This is a comma-separated list of category ID’s you want to use in the list. This option only applies if you are not using the excluded category IDs option.

Max posts per category

If you would like to show more than one post per category, you can change the number here. To display all posts, use 0.

Pages: « 2619 18 17 16 15 [14] 13 12 11 10 91 » Show All

  1. 210
    Koen

    Can I show more posts from each catagorie? I only have one catagorie.

    many thanks!

  2. 209
    Fred

    Thanks for a great plugin! Trying to get the plugin to show an image along with the category title, but can’t get it to work. I use the Yet another photoblog and all my posts are YAPB posts.
    I tried adding this and the file complies, but nothing shows up on the page:

    The tag for inputing a thumbnail of the post's image is: 
    <?php yapb_thumbnail('<div>', array(), '</div>', array('w=200', 'q=90'), 'thumbnail'); ?>  
    
    So I tried:
    $the_output .= yapb_thumbnail('<div>', array(), '</div>', array('w=200', 'q=90'), 'thumbnail');

    Any ideas? Thanks!

  3. Version 1.8 Released

    - The plugin has been tested, and works, with WP 2.6
    - The code now uses WP’s current_time function (instead of relying on the server time) to hide future posts.
    - Added an option to exclude categories (comma-separated list of cat IDs to exclude).

  4. I will be going through all my plugins soon to check for 2.6 compatibility.

  5. 206
    Jay

    Hey All,

    I have been pulling my hair out to display more posts and have found a way to display more posts but its not specific just shows the latest 5 posts. If you change on V1.7 line 294 i = 0 to 3 it will display 5 most recent posts.

    Hope that helps some people

  6. 205
    hello

    Hi, I like to find out is it possible to display the script not within the template file. Instead, I like it to display in another directory, and not within my blog directory. Pls advice

  7. [Quote]
    2) In a template file, insert the following code:[/Quote]

    What do you mean by ‘template file’? is it folder, .txt, .php, indext.php, single.php and so on.

  8. How would one go about including the first one or two posts from each particular category in the site’s RSS feed?

  9. 202
    Abel

    Hi Admin,

    This plugin is exactly what my client needs. :)

    I’m trying to exclude a category using the tip of Jesse last 8-16-06 (code below) but it doesn’t seem to work anymore for Wordpress 2.5 .

    I’d appreciate any help. Thanks!

    
    -In the script, find this line:
      AND post_status = 'publish' 
    -Right above it, add this line:
      AND {$table_prefix}categories.cat_ID  3
      (Where 3 is the category ID) 
    

  10. Hi,

    I have:

    added an option to remove category from output
    remove duplicate posts
    fixed invalid html tags
    optimsed html / php /sql for speed

    If you want to download my updated version of the code (1.7mattc) goto: http://mattclegg.com/blog/wordpress/latest-post-from-each-category-plugin-17-mattc

    mattc

  11. sorry to post twice in a row, but here’s a fix for anyone not scared to modify the code. just search for any instance of:
    AND post_date < NOW()
    and replace it with
    AND post_date < ( NOW() + 86400 )
    this lets the script look ahead in the future up to a day from now, which would compensate for any time differences and let you post from your own time zone without issue.

  12. I’m also having the problem with a delay between posting and this script picking it up. I think I’ve found out what the problem is however and I have a workaround. I live on the east coast, but my site is hosted on a server on the west coast. If I set the timezone to UTC -8 then the posts show up immediately. I think the script must compare the current time on the server to see what is new, but it can’t see posts from a few hours ahead of the server’s current time so it ignores them. If this was changed somehow so that it recognized posts that were posted after the current time then no one would have this issue.

  13. Can u tell me how do i configure your script so that it will look like the same shown in http://www.revenews.com

    Please check and let me know

    Thank You in Advance

  14. 197
    huzeyd

    Hi, thanks for plugin but i have a problem, i want show more posts from all category but this plugin shows a posts from every category how can i do it or if it is possible can you write a mini code for it, please. Thanks…

  15. (Reposting because it seems I didn’t need to html-quote everything, please delete the preceding comment. Thanks.)

    This simple patch adds a new option, that switches off the ‘per category’ part and just shows all recent posts, using the same formatting etc. I know that kind of subverts the purpose of the plugin, but it was what I needed to do. ;-)

    
    Index: dd-lastest-from-each.php
    ===================================================================
    --- dd-lastest-from-each.php	(revision 532)
    +++ dd-lastest-from-each.php	(working copy)
    @@ -19,6 +19,7 @@
     add_option('ddle_date_format', 'F jS, Y');
     add_option('ddle_excerpts', FALSE);
     add_option('ddle_chars', 200);
    +add_option('ddle_all_posts', FALSE);
     add_option('ddle_comment_link', FALSE);
     add_option('ddle_comment_num', FALSE);
     add_option('ddle_comments_none', FALSE);
    @@ -49,6 +50,7 @@
     		update_option('ddle_date_format', 'F jS, Y');
     		update_option('ddle_excerpts', FALSE);
     		update_option('ddle_chars', 200);
    +		update_option('ddle_all_posts', FALSE);
     		update_option('ddle_comment_link', FALSE);
     		update_option('ddle_comment_num', FALSE);
     		update_option('ddle_comments_none', FALSE);
    @@ -67,6 +69,7 @@
     		update_option('ddle_date_format', (string) $_POST["ddle_date_format"]);
     		update_option('ddle_excerpts', (bool) $_POST["ddle_excerpts"]);
     		update_option('ddle_chars', (string) $_POST["ddle_chars"]);
    +		update_option('ddle_all_posts', (bool) $_POST["ddle_all_posts"]);
     		update_option('ddle_comment_link', (bool) $_POST["ddle_comment_link"]);
     		update_option('ddle_comment_num', (bool) $_POST["ddle_comment_num"]);
     		update_option('ddle_comments_none', (bool) $_POST["ddle_comments_none"]);
    @@ -178,6 +181,13 @@
     		(0 = unlimited)
     	</td></tr>
     
    +	<tr valign="top"><td width="35%" align="right">
    +              Include all posts
    +	</td><td align="left">
    +		<input type="checkbox" name="ddle_all_posts" value="checkbox" <?php if (get_option('ddle_all_posts')) echo "checked='checked'"; ?>/>
    +              <br/>(This option disables the 'from each category' part of the plugin.)
    +	</td></tr>
    +
     	
     	</table>
     	</fieldset>
    @@ -213,8 +223,8 @@
     	$ddle_comment_num = (bool)get_option('ddle_comment_num');
     	$ddle_comments_none = (bool)get_option('ddle_comments_none');
     	$ddle_limit = (int)get_option('ddle_limit');
    +        $ddle_all_posts = (bool)get_option('ddle_all_posts');
     
    -
     	$hide_check = '';
     	if ($ddle_hide_protected) {
     		$hide_check = " AND post_password = '' ";
    @@ -292,11 +302,15 @@
     		}
     
     
    +        if (!$ddle_all_posts) {
     
    -	$used_cats = array();;
    -	$i = 0;
    -	foreach ($last_posts as $posts) {
    +            /* scan through and remove all but the first post from each
    +               category, unless we're including all posts. */
     
    +            $used_cats = array();;
    +            $i = 0;
    +            foreach ($last_posts as $posts) {
    +
     		if (in_array($posts->cat_name, $used_cats)) {
     			unset($last_posts[$i]);
     		} else {
    @@ -304,7 +318,8 @@
     		}
     
     		$i++;
    -	}
    +            }
    +        }
     	$last_posts = array_values($last_posts);
     
     
    

Pages: « 2619 18 17 16 15 [14] 13 12 11 10 91 » Show All

Leave a Comment

Before you comment: If you are having an issue with a script, please make sure you have read the entire article. Also, please read through the comments because most common issues have already been discussed many times. Thanks.


Be sure to wrap all code in <code></code> tags.