12.09.2024

05.31.2005

Just One Category

Filed under: wordpress @ 15:24

This plugin will cause WordPress to display on a category archive page only those posts which are direct members of that category, i.e. this plugin will exclude from that category page all posts which belong to any of that category’s subcategories but do not belong to the category itself.

Compatibility:
This plugin requires at least WordPress version 2.3 or higher, and I have tested it with the still-in-development WordPress version 2.8. If you haven’t already, upgrade to the latest WordPress.

Instructions:

  1. Download the plugin.
  2. Upload it to your wp-content/plugins/ directory (i.e. wp-content/plugins/just_one_cat.php).
  3. Make sure the file has sufficient File Permissions to be read by your web server (you probably don’t have to worry about this step).
  4. Activate the plugin called “Just One Category” from your Administration Panel’s Plugin Manager.

That should be it. No configuration is necessary.

Update: This plugin is now hosted on the wp-plugins.org repository. The download link above has been changed to reflect that.

52 Comments

  1.  

    […] hat category or any subcategory. The plugin is called Just One Category, for displaying only one category on a category page for all you […]

  2.  
    Randy 08.23.2005 @ 13:50

    Your Just One Category plugin seems to break my rss feed for the category.

    I was using the /wp-rss2.php?cat=3 to show the rss feed for category 3 and it was working just fine. Now I get these messages when I click on the rss link:
    ___________________________

    WordPress database error: [Unknown column ‘category_nicename’ in ‘where clause’]
    SELECT DISTINCT * FROM wp_posts LEFT JOIN wp_post2cat ON (wp_posts.ID = wp_post2cat.post_id) WHERE 1=1 AND 0=1 AND (category_id = 3 OR category_id = 4) AND post_date_gmt

  3.  
    Henrik 08.24.2005 @ 05:08

    I get the flw error on all categories:

    WordPress database error: [Unknown column ‘category_nicename’ in ‘where clause’]
    SELECT DISTINCT * FROM wp_posts LEFT JOIN wp_post2cat ON (wp_posts.ID = wp_post2cat.post_id) WHERE 1=1 AND (category_id = 1) AND post_date_gmt

  4.  
    Randy 08.24.2005 @ 08:31

    My page validates as XHTML but when I activate the plugin the page no longer validates.

  5.  
    MDA 08.25.2005 @ 02:28

    It wasn’t working because you’re not using Pretty Permalinks.

    I’ve updated the plugin so that it should now work no matter the URL you use.

    I can only assume your validation errors were a result of the plugin vomiting all over your page.

    In the future, note that it’s always easier for someone to help you if you give them a link to your site.

  6.  
    Henrik 08.25.2005 @ 03:41

    Yes, it works, thank a lot!!! – great plugin, just what I was looking for. Sorry for not including link.

  7.  
    abby 09.01.2005 @ 00:00

    Hello!

    I get this error, similar to Henrik… but I *am* using pretty permalinks. What do you think? I have queried specific categories (2,7,10,12,15,17,22,29) to be shown on the homepage. If you need me to re-activate the plugin, I will – in the meantime it is deactivated.

    WordPress database error: [You have an error in your SQL syntax near ‘2,7,10,12,15,17,22,29 GROUP BY wp_posts.ID ORDER BY post_date DESC LIMIT 0, 3’ at line 1]
    SELECT DISTINCT * FROM wp_posts LEFT JOIN wp_post2cat ON (wp_posts.ID = wp_post2cat.post_id) WHERE 1=1 AND (category_id = 1 OR category_id = 2 OR category_id = 7 OR category_id = 10 OR category_id = 12 OR category_id = 15 OR category_id = 17 OR category_id = 22 OR category_id = 29) AND post_date_gmt

  8.  
    MDA 09.01.2005 @ 00:16

    Do you mean that you have restricted the homepage so that only posts of categories 2,7,10,12,15,17,22,29 show up? If so, by what method?

    Henrik, no worries. Glad it suits you.

  9.  
    abby 09.01.2005 @ 09:12

    That’s exactly what I mean – I used query posts. Perhaps this is a nasty hack, but I make this stuff up as I go along. :)

    I put this before my loop:

  10.  
    abby 09.01.2005 @ 09:14

    Whoops, it’s very early in the morning yet for me. Guess I can’t put php code in my comment.

    surrounded by the requisite php tags I have (I hope this works since I can’t seem to preview my comment):

    $page = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;
    query_posts(“cat=1,2,7,10,12,15,17,22,29&showposts=3&paged=$page”);

  11.  
    abby 09.06.2005 @ 18:02

    Nevermind – I’ve ended up using front-page-cats to drive the posts on my home page (instead of the god-awful query posts above) and this is no longer a problem.

  12.  
    lellie 09.19.2005 @ 04:22

    THANKYOU!! this is just what I was after.. was about to write it myself until I stumbled across this.

  13.  
    Pingback from Because I Write»Blog Archive » Plugins 10.19.2005 @ 21:13

    […] Two plugins worth looking at and get tested for my …/emba site which are by Blogwaffe. They are Just One Category and Draft Notifier. • • •  […]

  14.  
    Paul 01.14.2006 @ 09:59

    This is great! I wish wordpress had this function natively.

  15.  
    BigBerries 08.14.2006 @ 02:29

    Hello and thank you for your plugin, this is looking to be a life saver. I have a question. How can the plugin be modified so the behavior is not global and work for a specific category and it’s children.

    Tried to change this
    if ( !is_category() )
    to
    if ( !is_category(Category Name) )
    but that doesn’t do it. Would be really thankful.

  16.  
    MDA 08.23.2006 @ 13:39

    BigBerries, The plugin simply is not designed to do what you ask. Without redefining what the plugin is supposed to do (and therefore rewriting the whole thing), the best solution is to:

    if ( !is_category('category-slug') )

    or

    if ( !is_category(cat_ID number) )

  17.  
    Nina 01.14.2007 @ 09:22

    Hi, what a great plugin! But I get the errors that Henrik got above. I tried to change to Pretty Permalinks but I still get the same errors…
    Maybe it’s because I use Widgets? I also use WP v. 2.0.6

    WordPress database error: [Unknown column ‘category_nicename’ in ‘where clause’]
    SELECT DISTINCT * FROM wp_posts WHERE 1=1 AND post_date_gmt

  18.  
    Nina 01.14.2007 @ 09:51

    Sorry I just realised that another plugin interferad mith yours, it’s a plugin that shows recent posts that generates the errors.
    Thanks for this plugin

  19.  
    Pingback from Just One Category : wordpressgarage.com 02.24.2007 @ 14:09

    […] Just One Category>> […]

  20.  
    Dermod Moore 07.07.2007 @ 05:53

    Hi there

    Great plugin, I hope to use it. But at the moment my sidebar widget that displays my recent posts is producing this error with your plugin installed:

    [Unknown column ‘category_nicename’ in ‘where clause’]
    SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts WHERE 1=1 AND (post_type = ‘post’ AND (post_status = ‘publish’ OR post_status = ‘private’)) AND category_nicename = ‘podcasting’ ORDER BY post_date DESC LIMIT 0, 5

    Any ideas?

    Thanks

    Dermod

  21.  
    don diego de la vega 07.23.2007 @ 03:44

    hi, a short questions for you experts:

    (I installed the plugin and activated it, but nothing new happens on my website… I hope it works…)

    the question is: may I place some code in the ‘single post’ page to show a list of all the posts of that same category?

    thank you in advance for your help!

  22.  
    Matt Kern 10.09.2007 @ 18:44

    I have also had the errors from posts 20 and 21 above.

    The post #20 error “Unknown column” I received while using WP 2.2.1 and the post #21 error (nothing happens) I received using WP ME2.2.3

    Thanks much. Hope to be able to use this handy plugin.

    Matt

  23.  
    Tim 12.15.2007 @ 11:15

    I get the following error too:
    Tried to deactivate other plugins but no go…
    any ideas?

    WordPress database error: [Unknown column ‘category_nicename’ in ‘where clause’]
    SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) INNER JOIN wp_term_taxonomy ON (wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id) WHERE 1=1 AND wp_term_taxonomy.taxonomy = ‘category’ AND wp_term_taxonomy.term_id IN (‘6’, ‘8’, ‘7’, ‘9’, ’11’, ’10’) AND post_type = ‘post’ AND (post_status = ‘publish’ OR post_status = ‘private’) AND category_nicename = ‘services’ GROUP BY wp_posts.ID ORDER BY post_date DESC LIMIT 0,1

  24.  
    MDA 12.15.2007 @ 13:38

    This plugin isn’t compatible with WordPress version 2.2 or greater. I’ll see if I have some time to fix it up over the next couple weeks.

  25.  
    Me 03.11.2008 @ 07:31

    How is it going MDA, already fixed the problems?
    Still not working for me though :(

  26.  
    MDA 05.09.2008 @ 19:24

    The plugin now works with WordPress 2.3 or greater.

    You should upgrade to WordPress 2.5.1 if you haven’t already.

  27.  
    GrooverFW 11.20.2008 @ 17:25

    Thanks so much for developing this plugin. I had an older plugin running on a website that did the same thing (no subcats), but just updated it to WordPress 2.6.3, cue plugin not working, site looking completely broken, tearing hair out etc. Had a quick search for a plugin, nearly gave up when I spotted a link to this page – installed plugin, site working perfectly again, life saved.

    Much respect!

  28.  
    Javier 12.03.2008 @ 15:55

    THANKS FOR THIS PLUGINS, BUT I CAN’T USE THIS PLUGINS ON MY WORDPRESS, CAN YOU HELP ME!

  29.  
    Pingback from Plugins « LEMP test 01.08.2009 @ 01:25

    […] plugins worth looking at and get tested for my …/emba site which are by Blogwaffe. They are Just One Category and Draft […]

  30.  
    wHiTeHaT 01.21.2009 @ 12:15

    Exelent … i searched 2 day’s for it.
    The name of the plugin is a little confusing, however i’m glad i found it.

  31.  
    Andrew 03.23.2009 @ 00:37

    Simple question – once installed, how do i use the plugin?

    Am I missing something basic here, or is there no documentation, screenshots on how to use this very necessary plugin?

    can’t wait to use though – good job, and thanks.

    •  
      MDA 03.28.2009 @ 12:56

      Just install and activate. There are no options. It just works.

      •  
        Ashley 07.14.2010 @ 05:39

        What do you mean “it just works”?
        How do I choose what category to display on which page?!?

  32.  
    Funny 03.27.2009 @ 10:20

    It’s not working with WP 2.7?
    Would you update the plugin please?

    •  
      MDA 03.28.2009 @ 12:57

      I have confirmed that it works with WordPress 2.7.1.

  33.  
    Bev 04.10.2009 @ 09:30

    Very nice plugin however it causes my Recent posts and my Most Popular posts sidebar widgets to stop working on the archive pages. I get the error:

    WordPress database error: [Unknown column ‘wp_term_taxonomy.term_id’ in ‘where clause’]

    and instead of articles, this displays for most popular:
    SELECT ID, post_title FROM wp_posts LEFT JOIN wp_ak_popularity pop ON wp_posts.ID = pop.post_id WHERE post_status = ‘publish’ AND post_date < NOW() AND wp_term_taxonomy.term_id = 244 GROUP BY wp_posts.ID ORDER BY pop.total DESC LIMIT 3

    and this for recent posts:
    SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_type = ‘post’ AND (wp_posts.post_status = ‘publish’) AND wp_term_taxonomy.term_id = 244 ORDER BY wp_posts.post_date DESC LIMIT 0, 3

    •  
      MDA 03.07.2010 @ 12:57

      Fixed in version 1.1.

  34.  
    kreso 07.12.2009 @ 11:10

    This plugin is must have for me .. dont know how could i live whitout it! Thanxxxx goes to great programer .. and as i can see you have great knowladge about architecture of WP .. not my leag :)

    Great work, and keep up good work!

  35.  
    veronique m. 11.03.2009 @ 19:26

    it’s beautiful
    i wished i could understand how it works
    a pity i had to modify it a bit, unfortunately, cause i needed to display the latest entries
    so, it applies only to the one category that has many subcategories,
    anyway,
    thanks !

  36.  
    Clint 01.22.2010 @ 15:26

    Greetings, I’m also getting the error: WordPress database error Unknown column ‘wp_term_taxonomy.term_id’ in ‘where clause’ for query SELECT SQL_CALC_FOUND_ROWS

    The nice thing is that the plugin still works. This is on WP 2.9.1

    Could I convince you to issue a fix for this bug?

    Thanks!

    Clint

  37.  
    Ingrida 03.11.2010 @ 21:12

    Strange thing happened with version 1.1 to me. It hide my home page category posts. It didn’t do that before. So I had to downgrade back to 1.0 Maybe you could tell me how to customize this plug in to act like a 1.0 then it comes to home page post?

    •  
      MDA 04.11.2010 @ 12:53

      I don’t know what you mean by “home page category” posts. Could you explain more?

      •  
        Ingrida 04.11.2010 @ 19:23

        Well, if you look at http://www.kawapanga.com homepage, there are categories displayed a bit lover like: “travel ideas”, “travel tips” and “travel the world”.Each show 3 recent emails with a thumb picture. After installing upgrade, it started showing just one post instead of 3. Originally my theme is showing 3 recent posts from those categories on a home page. Before this plug0in would not influence my home page, just normal posts. Now it disrupts work of my home page. Any idea how i could exclude my home page out of plug-ins influence field?

        •  
          MDA 04.13.2010 @ 13:46

          I sent an email to the authors of your theme. Hopefully they can send me a copy so that I can see what my plugin is doing that breaks your site.

  38.  
    Ralph 03.13.2010 @ 08:54

    Great and useful plugin but does not work for me after updating to 1.1. There seems to be a problem with newer categories/posts which are shown in the parent category although they belong only to the subcategory.

    •  
      MDA 04.11.2010 @ 12:53

      Hm. It works for me. What version of WordPress are you using?

      •  
        Ralph 04.23.2010 @ 07:27

        The latest version 2.9.2.
        I administrate two blogs with Just One Category. Both use WP 2.9.2, both have professional updated themes but one was broken after updating to 1.1 and the other one wasn’t. The broken one uses Gotham News by Woothemes, the other one Thesis 1.7.

  39.  
    Orachii 06.05.2010 @ 16:43

    I can not get this to work with 2.9.2. I installed it and NOTHING sub-categories still show up in main categories.

    Perhaps it’s one of my other PLUGINS messing it up can you test it?

    I have the following installed and active:

    1) Category Order
    2) Date Exclusion SEO
    3) Fast and Secure Contact Form
    4) Frontpage Manager
    5) Twitter for WordPress
    6) WP No Category Base

  40.  
    RDBerge 10.23.2010 @ 09:27

    I must be stupid because I have no clue how to call the functionality of this plugin.

  41.  
    Jens G. 03.03.2011 @ 15:35

    Hi

    the plugin is broken since WP Update 3.1
    Can you bring a Update for this Plugin please.

    Thx

  42.  
    Rich 12.22.2011 @ 13:51

    Michael,

    I think I fixed just One Category to work with newer versions of WordPress (since 3.1):

    In ver. 1.1 Change just_one_cat.php, approx line 39, reads:


    $just_one = $wpdb->prepare( " AND $wpdb->term_taxonomy.term_id = %d ", $cat );

    Change to:


    $just_one = $wpdb->prepare( " AND $wpdb->term_relationships.term_taxonomy_id = %d ", $cat );

© mdawaffe (Michael D Adams) - Powered by WordPress - Full Credits