RYO ‘Category Visibility’ WordPress Plugin

I needed a plugin that would display Posts only from certain categories. I found an earlier version of this plugin and modified it for my needs; then I supercharged it. Now I’m sharing it with you.

A good example of Category Visibility is this very website. It’s original purpose (in 2005) was to serve my web customers, most of whom wouldn’t have any idea how to install a plugin. I didn’t want plugin Posts to show to my regular users, but wanted to make the plugins available to other WordPress users who would want them.

See all of our WordPress Plugins

I created a WP Plugins category and unchecked “Front” and “List.” This kept these Posts off the home page, and the listing off the sidebar. (That’s all changed now. Users have a much greater understanding of plugins!)

The “WordPress Plugins” link above illustrates the point. It’s a link to the category page, which lists the plugins. You can see the category page and the associated Posts just fine. But that category did not show up in the sidebar, or on the home page. (It does now.)

This way, you could get access, in fact, anyone can search for them and find them. But they were not “out there” on the home page or in category links in the sidebar bothering my regular users.

Screenshot

RYO Category Visibility Options Page

History

I was using a WordPress plugin called Category Visibility (Keith McDuffee) which was written for WordPress 1.5.

It had a few odd points like when it filtered posts off the Home Page that was okay but it didn’t replace them; that is, if your front page was supposed to show 10 posts and two were filtered out, you’d only get eight posts. I fixed that and a few other tricky things.

It was wonderful, and lots of users agreed. Then WordPress 2.1 came out and broke everything. So I stuck with WP 2.0 for a long time.

No more! I woke in the middle of the night with an idea on how to re-think the logic and rewrite the whole thing from scratch. The new approach is more concise and takes fewer resources.

The result is faster, leaner, and, I hope, more likely to work with newer versions of WP. The same, familiar interface. Far more efficient.

Multiple categories on a post? Fine. The plugin tells WP which categories to exclude. This might not always be what you want. But it’s how it works.

There’s no upgrade path. If you’re using an older Category Visibility from one of the folks who tried to upgrade the old code, uninstall that first.

Instructions

  1. Simply download and unzip it.

  2. Put it in your plugins directory.

  3. Activate it.

  4. Go to Settings, RYO Category Visibility to see the visibility settings for all categories. the options are:

  • Front: Posts show up on the main (home) page.
  • List: Categories that will show up in the List of categories in the sidebar.
  • Search: Posts show up in search results.
  • Feed: Posts show up in the main RSS/Atom feed.
  • Archive: Posts show up in archive pages (i.e., clicking on the calendar links).
  • User Level: Numeric user level required to see these Posts.

Everything is checked to show up by default.

When you have a category to exclude from the front page, or the sidebar, etc., go to “Manage,” “Category Visibility,” and deselect the areas where you want the category to disappear.

This method is not designed as a security device, only as a display method. A guest can still access a post by post number.

Download

Download for WP 2.8+: Ver. 3.0.1.

Legacy version, WP 2.0.x: Ver. 1.0.0e. This plugin version only works in WordPress 2.0.

543 Responses to RYO ‘Category Visibility’ WordPress Plugin

  • pixelcow says:

    I’d really LOVE to use your Plug-In as it seems the exact solution to my “problem”. Too bad it’s not compatible with the 2.1-versions at the moment. I just want to hide the “Server-Status”-posts from the front page but keep them still accessible via the menu.

    There’s nothing to hide about my (self-so-called) server-downtimes or problems with ping-times and such stuff – but it messes up the “real” content from time to time.

    ad Ajani: think so too, waiting for it since version 1.x =:^)

  • ck says:

    For some reason your plugin causes posts to show multiple times even though only one shows in admin. Any ideas about how I could fix this?

  • Nate says:

    Beta is working great on v2.2.1, and fixes the multiple category – multiple posts problem! Great plugin! I agree, should be part of the WP core.

  • Eric Smith says:

    Andrew & ck, if you read the earlier comments you’ll see that you need the beta to avoid the multiple post problem. The 1.0.0e and earlier versions are NOT intended for use with WordPress 2.1 and later.

  • ruralmoon says:

    Problem: typing in the permalink of a post as the URL causes the post to be displayed even if the category it belongs to is not visible to the user.

    Solution:

    Modify the “cv_posts_where” function, add code as below.(use is_single() to determine if this is permalink)

    ...... elseif (is_search()) $where .= " AND (($cat_visibility.search=1 AND $lc"; // add permalink check elseif (is_single()) $where .= " AND (($cat_visibility.archives=1 AND $lc"; ......

  • graham says:

    I’ve installed this plug-in and it works perfectly, except on feeds.

    Categories that are not selected for feeds are still showing up.

    Any ideas?

  • Bob says:

    Just installed beta9 on WP v 2.1.2 PHP version: 4.4.4 MySql version: 4.1.21-standard Category Visibility version: 1.1.b9 (beta 9)

    and on another site running WP v 2.2.1 and all is working fine so far. Have not tested feeds yet, but hey, works for me on the home page which is the big picture.

    Thank you, great work on this.

  • ck says:

    I get this error when excluding category 12 from the front page:

    <p>WordPress database error: [Not unique table/alias: 'wp_post2cat'] SELECT SQL_CALC_FOUND_ROWS distinct wp_posts.* FROM wp_posts LEFT JOIN wp_post2cat ON (wp_posts.ID = wp_post2cat.post_id) LEFT JOIN wp_catt_visibility ON (wp_post2cat.category_id = wp_catt_visibility.catt_ID)LEFT JOIN wp_post2cat ON wp_post2cat.post_id = wp_posts.ID WHERE 1=1 AND (post_type = 'post' AND (post_status = 'publish')) AND ((wp_catt_visibility.front='1' AND wp_catt_visibility.cv_user_level&lt;='0') OR post_type='page' OR wp_catt_visibility.catt_ID IS NULL) AND wp_post2cat.category_id NOT IN (12) ORDER BY post_date DESC LIMIT 0, 10</p>

    Seems to work fine for excluding it from the feed though. I really wish it would work with feedburner plugin too.

  • lucy says:

    Just installed on 2.0.1. works out of the box, perfect, just what i needed. Looking forward to the full version for my 2.1.2 upgrade..

  • Bryce says:

    I’m sorry, I started reading through these comments to see if my question is addressed but there were too many! And I’m lazy!! Anyway, this plugin works great when simply navigating through the front page and using the Previous and Next Entries links. However, if you navigate directly to an individual posts page and a “hidden” post is the previous or next post, you can access them this way.

    Hopefully I explained that semi-coherently. As an example, if you click on my “Garlic Powder” post directly, you can then click on the post prior (“I know we’ve only…”) and view it, even though it belongs to a hidden category.

  • David says:

    I’ve just added v1.0.0e to my WP2.2.1 site. All seems well apart from as per Bryce’s comment above. I can still request a page from the url with ?p=XX and it will return the page. Also categories that are surpressed by userlevel still show the number of entries in the catgories part of the sidebar even though they don’t show the category name. Thanks

  • David says:

    Ooops! Upgraded to 1.1.b9 (beta 9) (still on WP 2.2.1!) – category sidebar no longer shows number of entries for suppressed categories, but I can still navigate to pages in surpress categories. Thanks again.

  • Mark says:

    Greetings -

    For some reason, the category pages that I have created do not get picked up when I do a technorati ping? Does anyone know the reason for this?

    Thanks, Mark

  • Andreas says:

    Hey, thanks once again for a GREAT plugin! I have a couple of questions:

    Is this plugin still in development? Will you add any more features (or options) soon, and would it be OK to send you a feature request? If so, I would be happy to sponsor the plugin with a donation since this plug is incredibly useful. Feel free to write me a line if this sounds interesting.

  • Hal says:

    Great plugin – does anyone know how to set catergories into a particular order ie with a plugin /hack . Any help much apreciated.

  • Hal says:

    Ive found one and its brill http://geekyweekly.com/mycategoryorder/ its a plugin that sets a widget and you just swap it for the existing category. Not sure if it will work with this “cat.visi” plugin though as ive deactivated it for now. Thanks

  • Vic says:

    Thank you for such a great plugin list. For the new person this list are just priceless.

    Thanks

    Vic

  • Lorna says:

    Thanks for the plugin. I was simply looking for one that can filter out a category out of my home page and RSS, so it’s working perfectly with my WP v.2.2.1 blog.

  • ilia says:

    ruralmoon,

    I’m trying to add your code but it comes back with error. Is it suppose to work under Wp v.2.2.1?

  • Tim says:

    same question as above (haven’t tried it yet though beacause me renting a host depends on this plugin working…)

  • notoriousxl says:

    If I activate it under WordPress 2.2, my “Categories” page (based on the archive template) looks strange: the categories’ hierarchy is modified.

  • notoriousxl says:

    sorry, in my last post I forgot a “.2″… is “WordPress 2.2.2″ :P

  • Bruce says:

    Thanks Rich for this great plugin, i’m goint to install it right now ;) Bruce

  • melanie west says:

    i have installed & activated it without any problems. unchecked the categories i do not want to be show up but it doesn’t seem to work. i check my website from another computer and in another browser just to make sure & all the categories are still there. is there anything i missed?

    thanks!

  • Rene says:

    Seems a nice plugin, but is there any chance an update will be made compatible with WP 2.2.2 ? (also widget-compatible)

  • Rich says:

    Probably not. WordPress has become so aggressive with new releases (a good thing, in general) that I am unable to keep up with them. From the comments, it appears it still works for a lot of folks, so while no longer “perfect,” it remains of value.

  • mark says:

    Sorry, I’m a simple guy and don’t understand all the finer coding things. But is there a way of getting rid of the post counts and arrow placeholders – see http://www.theworldsbesthomepage.com for example of what I am left with. Thanks.

  • Ralf says:

    I have greatly enjoyed using this plugin (and its predecessor) for the last ten months.

    Unfortunately though, the upgrade to WordPress 2.2.2 and Gengo multilingual plugin caused Cat_Vis to break. I cannot see individual post pages anymore. I can’t use the previous posts button etc…

    There’s no going back now. I thus have to stop using category visibility :(

    Finding a good replacement was difficult as the most obvious alternatives acted on a per-post basis. That means that I would need to edit all my 60 private posts now, and also remember to assign rights to EACH new private post now and forever. What a hassle!

    Anyway, I found a replacement. Not as good, but at least it’s error free and it lets one assign CATEGORY access rights to anonymous readers and something called “new users” (?). Testint about to begin…

    It’s called category access and it’s available at: http ://www.coppit.org/code/

    Hope you too find it usefull.

    ps. I am not related in any way to the author of that plugin.

  • Manele says:

    I have just installed your plugin on a new blog I am doing and first – thank you!

  • Frank says:

    b10 works great on my site! thanks a bunch

  • Frank says:

    ok spoke a bit too soon. it works beautifully until you try and go to an individual post. then i get this 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 'ORDER BY post_date DESC' at line 1] SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND YEAR(post_date)=’2007′ AND MONTH(post_date)=’2′ AND DAYOFMONTH(post_date)=’25′ AND post_name = ‘gap’ AND (post_type = ‘post’) AND ((wp_catt_visibility.archives=1 AND wp_catt_visibility.cv_user_level<=’10′) OR post_type=’page’ OR wp_catt_visibility.catt_ID IS NULL ORDER BY post_date DESC” any ideas on how to fix it?

  • Jenn says:

    Getting the same error as Frank above. Post pages return that error and can’t be displayed when the plugin is activated (the most recent beta).

  • atombong says:

    I’m getting the same error, Frank. I’d love to get this working… any help would be appreciated!

  • robs says:

    I would like to have how default all the categories hidden; can you suggest which is the cahnge that I must to do?

    Now by default in admin all the categories are checked and if you remove checked you can hidden categories;

    I would like to have the opposite: I think there are two solutions: -1 by default if all is checked then the categories are hidden and if I remove check I can see it; or 2 by default all isn’t checked and I not see categories; only if I check I see categories;

    I think found the parameter for to change but have always problem that if one click same time button submit changes all checked switch at every click; can help

  • I just converted over to WP2.3 and I got this error when running the plugin

    WordPress database error: [Table 'thetinym_wordpress.wp_post2cat' doesn't exist] SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts LEFT JOIN wp_post2cat ON (wp_posts.ID = wp_post2cat.post_id) LEFT JOIN wp_catt_visibility ON (wp_post2cat.category_id = wp_catt_visibility.catt_ID) WHERE 1=1 AND post_type = ‘post’ AND (post_status = ‘publish’ OR post_status = ‘private’) AND ((wp_catt_visibility.front=1 AND wp_catt_visibility.cv_user_level<=10) OR post_status=’static’ OR wp_catt_visibility.catt_ID IS NULL) ORDER BY post_date DESC LIMIT 0, 7

    Any thoughts?

  • Joe says:

    If anyone finds a way to make this work with WP2.3 please post here, I’m desperate to find a plugin with this functionality for WP 2.3!

  • Hans says:

    Hi,

    Just upgraded to 2.3 and unfortunately I get the following error (top of page):

    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 'ORDER BY post_date DESC' at line 1] SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND MONTH(post_date)=’6′ AND DAYOFMONTH(post_date)=’18′ AND post_name = ‘the-colonial-inn’ AND post_type = ‘post’ AND ((wp_catt_visibility.archives=1 AND wp_catt_visibility.cv_user_level<=’10′) OR post_type=’page’ OR wp_catt_visibility.catt_ID IS NULL ORDER BY post_date DESC

    and in the sidebar: WordPress database error: [Table 'leisurep_wordpress.wp_categories' doesn't exist] SELECT * FROM wp_categories LEFT JOIN wp_catt_visibility ON (wp_categories.cat_ID = wp_catt_visibility.catt_ID) ORDER BY wp_categories.cat_name

    I understand the categories table doesn’t exist anymore but how do I fix it, what to do?

    Thanks

    Hans

  • NoName says:

    Reese Hopkins > i have the same error:-(

  • Zadro says:

    i need this for WP2.3 Please! :-/

  • Rich says:

    Sorry, no version for 2.1 or later.

    As noted in the download section above, “Alas, everyone wants to know when the new version will be ready. It probably won’t. As I was testing the 2.1 version WP released 2.2 and I realized I can’t keep up. Still, some folks are finding this very useful, so I’ll keep it here for you and maybe someone else will pick up the ball.”

  • bvo says:

    I’d like a 2.3 version too!! Anyone taking over from Rich?

  • Cosme Faé says:

    i need this plugin for WP2.3 too! =/

  • ProjektSeven says:

    Dudes: I just spent an hour or two and fixed this thing to to work with WordPress 2.3, so if you want it, email me: biotechnique (at) gmail (dot) com

  • Chuck says:

    This is one of those plug-ins that I would be happy to pay for. Bet there are a few others who would too!

  • elfox says:

    i need this plugin for wp2.3 thx.

  • Matt Davies says:

    This is a great plugin! I REALLY WANT IT TO WORK IN 2.3! ProjektSeven, why not submit your update to this site? Loads of us want it!

    Matt

  • ProjektSeven says:

    Okay Kids, I said I had it, and I will a) email those who emailed me (tonight), and b) post it on some domain somewhere so that you can grab it tonight. It is missing some functionality because I didn’t need it for my purposes, but if you want to fix it it’s all still there…I don’t have the time.

    Open source rules; people who make you pay for plugins should be spammed.

  • kapeka says:

    ProjektSeven: Where is that “some domain somewhere”? I’m heavily interested in a fixed plugin fpr WP 2.3. Do you still accept emails?

    thx kp

  • resim says:

    great plugin and it is working with wordpress2.3 thanks…

  • Philipp says:

    Hey!

    The Entries in the RSS are duplicated, also with the Beta10. But the rest is fine. http://www.engarde.at

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>