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.8   Updated Thursday, August 14th, 2008 at 8:20pm

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

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

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

Pages: « 1511 10 9 8 7 6 5 4 [3] 2 1 » Show All

  1. 45
    Jesse

    Do you mind if I post the modifications I have done to your plug in, and a link to my website which will demonstrate what it looks like?

    Also I also plan on adding a plugins used section to one of my columns which will have links to the sites so others can find them.

  2. Jesse: Ah yes.. I have a habit of using that function for that *grin* That is what I get for not testing it ;)

  3. 43
    Jesse

    I was taking a look at your code today, after I noticed I was not getting the … to output when my text was longer then desired excerpt length. I found that you are using the sizeof() funtion for $the_text it looks like this sizeof(strip_tags(trim($the_text)). I did some research and found that sizeof() is meant for an array I replaced that with strlen() and everything seems to be fine now.

  4. 42
    Jesse

    I was so tired last night I copied and pasted a piece of code (in message 43) it is from a different plugin SORRY! Note to self: When your tired take your time when writing messages.

    Heres the if statement that I fixed:

    
    if ($ddle_comment_num) {
      $the_output .= $num_comments . ' Comment';
        if ($num_comments != 1) {
          $the_output .= 's';
        }
    } else {
     $the_output .= 'Comments';
    }
    

    The else only addresses if $num_comments is zero, the nested if address if not 1 but does not address if it is one. So I moved the else to be part of the nested if. Now when $num_comments is zero, nothing is displayed and if $num_comments is 1, 1 comment is displayed. And if its not 1, 2 comments is displayed.

    I hope this addresses the confusion I made below again I appologize I was quite tired from stareing at the code too much. Please remove Post 42 and 43 it wont help anyone.

  5. Jesse: Last one for tonight :P

    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 of the cat you want to hide. If you wanted to hide multiple categories, just duplicate that line for each one, and set the number. If you are not sure what the ID of your category is, it is listed under ‘Manage > Categories’ in the WP admin panel.

  6. 40
    Jesse

    I know this is a bit more away from the scope, but I have a News category which is displayed on my homepage, with this plug-in right below it. This plugin displays the news category again. In this case I have a redundency of the news. Would it be possible for me to make another request.

    Can you make it possible for a given category or categories to not display?

    Thanks Again,
    Jesse

  7. Jesse: A lot of them do, but not all people take advantage of the feature when writing plugins :)

  8. 38
    Jesse

    Nice work, that options area is a nice touch. Do most plug-ins have a feature like that. I really like it.

  9. Jesse: Check out the new version ;) Read the changelog, and take a look at the new options (most are disabled by default - so be sure to enable them). Enjoy!

  10. 36
    Jesse

    I was thinking the same thing about the Top X Number of posts, but Im looking into the future of my site. And I use catagories to track Projects. Once projects are complete there will be almost no update to these catagories. And the number of catagories I am going to use is going to be outrages.

  11. Jesse:

    1) Good idea
    2) Even better idea
    3) Maybe, but the point is to show the latest from each category

    Give me a few mins ;)

  12. 34
    Jesse

    1. So would the option for displaying a link to the comments each post be an option?

    2. Removing the “…” after the contents if the contents are less then the allowed characters?

    3. Only display the top X number of posts?

    I think I will limit my requests to that for now. I am willing to help but I dont know how much help I would be.
    Thanks,
    Jesse

  13. Jesse: Your question makes a lot more sense now :)

    I think I see the problem. Those options you are changing in the file are only the default options for the first time the script runs. After that, they are no longer used.

    To change the options of this plugin, Go to ‘Options -> DDLatestFromEach’ in your admin panel :)

  14. 32
    Jesse

    Sorry about the mess you needed to clean up.

    Im trying to get the content to diplay for resent post of all categories.

    I have the options set at:

    add_option(’ddle_excerpts’, TRUE);
    add_option(’ddle_chars’, 200);

    but no content is displayed.

  15. Andy: The PHP in Pages plugin sometimes works well for certain things, but not for everything. I would not try using that code directly in a post/page. It needs to be added into your template file directly - wherever you want it to show up.

Pages: « 1511 10 9 8 7 6 5 4 [3] 2 1 » 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.