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.6   Updated Sunday, April 27th, 2008 at 8:20pm

Other Posts from Cat plugin for WordPress

This plugin will show the last X posts from the current category at the bottom of every post, or where you manually specify in each post. Using the built-in options page, you can choose the number of posts to show, set the header text, choose to show the post dates, select the format of the date, and choose whether or not to include the current post in the list. The latest version also has an option to show recent posts from all categories the current post is in.

Download

  • Latest Release (For WordPress 2.0 through 2.5)
  • International Version (For WordPress 2.0 through 2.2)

    One of our visitors sent in an internationalized version of this plugin, with full support for international text and date formatting! It includes English and Spanish support. This version is only supported by WordPress 2.0 through 2.2, and will not work in 2.3 or 2.5

Instructions

  • 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 DDOtherPostsFromCat).
  • Test it out by viewing a post.

Change Log

  • 04-27-08 Version 1.6 Added an option for excluded categories. Also a few other minor fixes.
  • 09-29-07 Version 1.5 Updated for WordPress 2.3. Added ‘Load Default Options’ button.
  • 06-11-07 Version 1.41 Added wrapper class around output (.ddop)
  • 05-16-07 Version 1.4 Updated for WordPress 2.2.
  • 01-28-07 Version 1.3 Fixed an issue in which a database error would occur when the plugin is set to check all categories that the post is in, and it is in only one.
  • 08-09-06 Version 1.2 Now if showing posts from all categories the current post is in, you can also choose to split them up into multiple lists (per category).
  • 08-08-06 Version 1.1 By request, the plugin now features an option to show recent posts from all categories the current post is in. It also has a CSS class added for easy changes.
  • 04-19-06 Version 1.0 First release. This is very similar to my ‘Posts by Author’ plugin but it lists other posts from the same category, instead of other posts by the current author.

Notice

Currently this plugin checks the first category a post is assigned to when generating a list of other posts in the same category. This means that it will work best for those of you who only assign one category to posts.

Styling

This plugin now has a div wrapped around the output with the ddop class assigned to it. For example, if you wanted to decrease the size of the text in the output, add this to your CSS file:

.ddop { font-size: 90%; }

Options

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

Show at the bottom of every post

If enabled, this plugin will generate its data at the bottom of every post, before the comments section.

NOTICE: No matter what you have this set to, you can also manually call this plugin by entering the following line where you want the data to be shown in your post:

<!-- ddpostsfromcat -->

Check all categories that current post is in

With this option enabled, recent posts from all the categories (that the current post is in) will be shown. It will also show all of these categories in the heading (if you are showing one). Disabled, it will simply show other posts in the first category this post is found in.

Split categories into separate lists

This option only applies if the previous option (check all categories that current post is in) is set. It will allow you to split up the posts into multiple lists (per category) instead of all the posts being in a single list.

Number of posts to show from this category

This is the number of posts from the current category that will be shown.

Text to show before list

This is the header for the post list. If you want to use the category title in this text, use %C.

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)

Include current post in list

This sets whether or not the post being viewed should show up in the list of other posts from this category.

Show newest posts first

If checked, this will show the newest posts first in the list. If not checked, it will show the oldest posts first.

Excluded Categories

This is a comma-separated list of category names you want excluded from this plugin. It is not case sensitive.

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

  1. Hi. Thanks for this great plugin.

    I’d like to integrate this into my current theme. I don’t want the titles to show up UNDER the posts but NEXT TO them. And I don’t want to manually configure this for every single post, by writing for each post.

    I tried to include this in the single.php but it didn’t work.

    How can I make it?

    Thanks.

  2. Rod: You can place it wherever you like. By default, it is added to the bottom of the posts, but if you prefer, you can use the trigger text in your post or page to manually specify the position:

    <!-- ddpostsfromcat -->

    Of course, if you want it aligned to the right for example, you could wrap it in a div, which is styled to float to the right, etc..

  3. OK, all is right. Your plugin is very fantastic … my english is quite bad, and some of your options were not easy to understand when you don’t speak like Shakespeare :) So … the only thing which misses to your plugin, is the possibility to put where you want (in my example : on the right of the post)

  4. ahahah first comm’ and great Newbie attitude I had !!! :) OK for the options of “all categories” … it would be nice so to separate each category instead of a list of “all” :)

    So … the only thing which is wrong is the code which doesn’t work if I want to place the list somewhere else.

  5. doesn’t work for me …
    1. first problem : if I chek “show under the post” … I choose 5 post … and I have in H2 > “The last 5 articles from “Category” … and I have not 5, but 10 :)

    2. The worst : I WANT to place when I want inside the post page (and whynot the index, but in this case, the post page) the code … and … it’s not interpreted. When I see the source, I see :

    
    <dt>Derniers articles</dt>
    <dd> <!-- ddpostsfromcat --> </dd></dl>
    

    So … I’m on WP 2.1.2 and php5.2 . A feature would be great : you have the choice between the “current” category and “all” categories. But if I take my example (a post inside 2 or 3 categories in same times, for example : Bars, Concerts, Photos … it would be nice to have an option to list the xxx posts from each category where the post is. Possible ?

  6. João: It is, but you have to modify a couple of things. First you need to add a parameter called $c_cat to the ddop_show_posts function, and remove the two lines near the top of that function which set $c_cat. Then call the function like this:

    <?php echo ddop_show_posts(123); ?>

    There is also a declaration of $c_post in the function, which you will just need to set to 0.

  7. Great Plugin!

    As a newbie, I was wonderng if it is possible to call the function from outside the loop , specifying the category, such as .

    As I understand i can call the php functions to some other file, and execute the query, but it must be to an specific category?

    Thanks!

  8. Cent: Here is something you can try. Change this line in the script:

    if (mysql_num_rows($cat_list)) {

    To this:

    if ((count($cat_list) > 0) && (mysql_num_rows($cat_list))) {

    As far as the sidebar, this plugin has to be executed within the actual post loop so it will know what post is being displayed. It will not work properly in the sidebar since it will not within the loop, and cannot see the post data needed.

  9. 67
    Cent

    Hi. Just installed this plugin on WP 2.1. Two things… The plugin is installed fine and shows the other posts in the same categories fine. However, just where the post begins on my single.php page, I get the following error:

    Warning: mysql_num_rows(): supplied argument is not a valid 
    MySQL result resource in /home/virtual/site2/fst/var/www/html/
    content/wp-content/plugins/other-posts-from-cat.php on line 195
    
    Warning: mysql_num_rows(): supplied argument is not a valid 
    MySQL result resource in /home/virtual/site2/fst/var/www/html/
    content/wp-content/plugins/other-posts-from-cat.php on line 195

    However, the plugin does seem to be working as it shows the other posts at the bottom of the current post.

    My 2nd question is, I don’t want to show these categories and other X posts from them at the bottom of my main post, but in the sidebar. How can I do that?

    Thanks
    Cent

  10. Merkal: It would be possible yes, but the plugin currently uses a single list of posts and they are not separated by category.

  11. Fine plugin just what I needed for, The admin tab is a great addition too. Now my question is about the option to output post from multiple cats. Is it possible to get to lists next to each other instead of under each other? Perhaps with CSS floats or by using good old tables. thanks

  12. John: I just uploaded version 1.3 - let me know if it fixes the issue for you. It looks like when the option was set to search other categories the post is in, but it is in no others, it was not processing the category list properly.

  13. The () comes from here:

    
    if ($ddop_other_cats && !$ddop_sep_cats) {
    
    	// show other cats too, but in one list
    
    	$category_check = " WHERE (";
    		
    	$i = 1;
    
    	foreach ($cat_list as $c) {
    
    		$category_check .= " category_id = " . $c->cat_ID . " ";
    
    		if ($i < sizeof($cat_list)) {
    			$category_check .= " OR ";
    		}
    
    		$i++;
    
    	}
    
    	$category_check .= ") ";
    

    The $category_check is throwing an error and that’s why the () ends up empty.

  14. John: Hm.. that WHERE line should not just have an open and close parenthesis after it like that. It looks like that is causing the error. You can remove the () and the AND right after it, so it looks like: WHERE wp_posts.ID etc..

  15. I’ve tried !=, and NOT IN (7,8) - all produce the same error:

    
    WordPress database error: [You have an error in your SQL syntax; 
    check the manual that corresponds to your MySQL server version
     for the right syntax to use near ') 
    			AND wp_posts.ID = wp_post2cat.post_id 
    			 AND ID != 59  
    			AND post_s' at line 3]
    
    			
    			SELECT DISTINCT ID, post_title, post_date, post_category
    			FROM wp_posts, wp_post2cat 
    			 WHERE () 
    			AND wp_posts.ID = wp_post2cat.post_id 
    			 AND ID != 59  
    			AND post_status = 'publish' 
    			ORDER BY post_date  DESC  
    			LIMIT 5
    

Pages: « 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.