‘Category Visibility’ Plugin for WordPress 2.0.x

‘Category Visibility’ Plugin for WordPress 2.0.x



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; now I’m sharing it with you.

A good example of Category Visibility is this very website. It’s purpose is 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 keeps the Pages off the home page, and the listing off the sidebar.

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 does not show up in the sidebar, or on the home page.

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

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 changed that to run a select that does the filtering; as a result you get the full 10 posts.

There were a few other tricky things.

  • With WordPress 2.0, user levels are diminished and replaced with Roles. In some ways, this is better. If you’re not using any other old plugins which require numeric user levels, you have even more control. Use Owen Winkler’s Role Manager Makes it easy to add Roles and change the user level number associated with a role. Then use Category Visibility to control what those users see. A numeric code makes it possible to add permission to more than one user Role with a single entry.

  • Return category archives when called by cat ID. the original author must have used permalinks, because it wouldn’t work without permalinks. And there was some kind of problem if you had the category as part of the permalink. I’m pretty sure that’s been resolved.

  • Handle empty entries, that is, categories where no Category Visibility rule has been set. If you set up a new Category, you had to go to Category Visibility to set the user level, or it wouldn’t show. Now, that’s not required. By default, categories are visible to all.

  • CV was excluding Pages from search results when the Page was associated with a Category which was not supposed to be visible (Uncategorized). Since Pages aren’t really part of the Post/Category system, we don’t want them excluded, so I fixed that.

  • Allow administration only to those who have a Role that can Manage Categories.

  • Upgrade from the older WP 1.5 Category Visibility (0.31 by McDuffee). If you upgrade, be sure to deactivate the old plugin, then activate the new one, to initiate required changes to the database. You’ll also need to reset the visibility choices; this new version uses an entirely different table, purely to allow you to step back to Keith’s version if you prefer.

This plugin only works in WordPress 2.0. (Currently not compatible with 2.1.)

Instructions

  1. Simply download and unzip it.

  2. Put it in your plugins directory.

  3. Activate it.

  4. Go to “Manage,” “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 links (i.e., clicking on the calendar links)

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

Latest version, WP 2.0.x: Ver. 1.0.0e.

  • Added a function, cv_get_posts(visibleto), which duplicates the WordPress get_posts() function except that when a category is not passed, it returns posts in visible categories only. Defaults to those visible in ‘list,’ but can be changed using the ‘visibleto’ parameter.

A 2.1/2.2+ version that might work for you? Due to the urging of early adopters, I hacked at the catvis system to see if I can get it to work with 2.1. Here’s an early copy. It won’t hurt anything. But, from the comments I received, it probably won’t do the job. (I use WP 2.0.) MySql 4.1 no longer required for standard use. Download Beta9.

Some folks had suggestions, which I incorporated into Beta 10. Download Beta10.

One user has updated this for 2.3. (I haven’t tested this because I have NO 2.3 systems. Check:
http://www.tastycornbread.com/category-plugin/.

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.


384 Responses to “‘Category Visibility’ Plugin for WordPress 2.0.x”

  1. Balaji Dutt Says:

    Hi,

    I was trying to get the Private Categories 2 plugin to work on my site, but it kept breaking in IE.

    Found your plugin through a search and it works like a charm!

    Great work and thanks!

  2. Luis Says:

    Thanks, it seems the original author has dropped this project. Your work is very much appreciated.

  3. Luis Says:

    Update: I found a bug.

    You need to add support for child categories. That is, categories that are made under a parent.

    If you get that fixed it is perfect.

  4. maira Says:

    Thanks a lot for updating this essential plugin!!! I was starting to be afraid that I’d have to rebuild my whole site until I read your message at gudlyff’s.

    And many thanks also for your improvements, specially for the default visibility for new categories.

    Maira

  5. Rich Says:

    Thanks, all.

    Luis, caught the child cat bug. (Would a child cat be a kitten?) Squished the bug and uploaded v. 1.0.0a.

    Maira, thanks. That drove me nuts. Also, when you’d set up a new system and activated the plugin everything was fouled up til you went in and initialized the database. Now it’s created when you activate the plugin.

    Rich

  6. Rich Says:

    Category Visibility seemed to be creating a lot of mysql queries, so I modified it a bit to cache results and it made a difference. In my somewhat high-overhead theme it reduced the query count by about 18, which I consider significant.

    So, if you want a Category Visibility that runs faster, download 1.0.0b.

    Rich

  7. Martin Says:

    Great! I also ran into the Filter problem with Keith’s plugin. This one worked as a out of the box replacement.

    THX
    Martin

  8. Rena Says:

    Thanks for carrying on with this plugin. It’s of definite value.

    Any chance you’ll add support for turning on/off visibility of pages for wordpressers using list_pages or wp_list_pages in their sidebar. It would be great not to have to muck around in code in order to display/exclude particular pages.

    Thanks!

  9. Rich Says:

    Rena,

    About “..support for turning on/off visibility of pages for wordpressers using list_pages or wp_list_pages in their sidebar…”

    I think that would be a different animal. (Not a catt plugin.) You’d have to check for a specific custom field or template to exclude the Page from the list.

  10. oneunshamed Says:

    found another bug.

    When you have multiple loops set up on your front page, your plugin does not just kill the category from showing up in main loop, it kills them from showing up in any loop on the front page.

    one plugin i found that avoided this was: RumCategory,
    however, it is not nearly as robust as this one, therefore i would hope that you could arrange it to only kill the main loop in index.php

  11. oneunshamed Says:

    Upon further inspection, i have found that this issue is only created when making the “archive” invisible, all of the other options behave as they should when un-ticked.

    The solution is in somehow allowing users to hide posts from the archive, without completley eliminating the category all together (which is what the plugin in is seemingly doing ).

  12. Rich Says:

    Well, we could debate whether or not that’s a bug, but that would serve no clear purpose.

    It’s our intention that when you uncheck something off the front page, that it is, in fact, off the front page.

    The ‘list’ is supposed to refer to the sidebar.

    We run two loops on many of our fromt pages, the first is the main loop, the second is an “additional headlines” loop. We expect excluded categories to be excluded there, too.

    I can understand that there might be cases where you’d want something else. You’d probably need to modify your index.php to set some kind of a a flag and modify the Category Visibility plugin to not react when the flag is set.

    Now it just recognizes that it’s the home page (through a process of elimination) and works accordingly.

    About the archives business, that has created a number of perplexing situations. We’ve somehow fixed most of them, but a few persist. I’ll probably go look at that sometime; can’t promise when.

    Note that there’s a little internal function in there now called cv_visible_cats(). It takes one parameter, a string that says front, list, seach, feed, or archives, defaulting to front. This returns an array of categories visible to the respective area.

    It might be possible to use that for special purposes; we do that.

    // cats visible to front page
    $acats = cv_visible_cats('front');
    $catlist = '';
    foreach ($acats as $category) {
    $catlist .= ' ' . $category->cat_ID;
    }

  13. oneunshamed Says:

    hmm, not quite sure if i know how to implement that the right way, however i have used this in conjuction with your plugin by not hiding anything from the archives in your UI, and then going in and hiding them manually in my index.php

    here is a sample of my code:

    < ?php if (is_category()) { ?>
    <h2>< ?php _e(’Archive for’); ?> < ?php echo single_cat_title(); ?>

    < ?php } elseif (is_month()) {

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("paged=$paged&cat=0,1,2,3,4,5,6,7,8,9,10,11"); ?>

    <h2>< ?php _e('Archive for'); ?> < ?php the_time('F, Y'); ?>

    basically i am telling wordpress what categories to show at any given time, whatever category numbers arent listed above, are not displayed. This however is a hassle, so please fix yours :P

    hope this helps

  14. Steph Says:

    When the plugin is activated, and i turn off certain categories from the archives it still displays the months where the certain categories are but then when the months are clicked on it says the page you are looking for is not there. Is there a way to make the month not be displayed if the category is turned off?

  15. Mike Evangelist Says:

    Great plug-in! Thanks.

    I think I’ve found a problem though; I have a category with a apostrophe in its name: ‘Jobs I’ve Known’. With the plug-in operational that category does not show up in the sidebar (even though all the checkboxes are ‘on’). If I edit the category name to remove the apostrophe, the category appears correctly. Any way around this?

    Mike

  16. Kathy Moore Says:

    Thank you so much!

  17. Rick Says:

    Awesome!

    Thanks Rich, just about perfect. What would be great is to have a ‘per post’ option. Meaning that when I write my post I can set whether I want it on the front page or not (but still have it publish to cats). There is something similar to this in mambo/joomla.

    Thanks anyway. Great plugin, easy to use!

    Rick.

  18. shelbinator Says:

    Excellent plugin!
    However - for those of us looking for extra discretion, it would be even more excellent if there was a way to turn off visibility in the calendar as well. I have a test category “invisible” and deselected all of the visibility options for it, but the post I just wrote in that category still causes that day (today, 6/15) on the calendar to become a link, and a mouseover shows the title of the post. Just a thought for any future revision - suggestions for a hack welcome. :-)

  19. JP Says:

    This is very sweet. I was wracking my brain (and the support forums) trying to figure this out until someone linked me here. I haven’t implemented it yet, but just reading, it’s exactly what I was looking for. Keep me posted of any updates!

  20. JP Says:

    D’oh! I just installed it, and as I was doing so I thought to myslef “hmmm, I wonder if this is going to work with Sideblog 2.0 (By Kates Gasis)” and sure enough, it doesn’t. Had both activated and it snafu’d on yours, deactivated Sideblog and the main page works but now no ‘updates’ sideblog in the sidebar. Any thoughts?

  21. Rich Says:

    It doesn’t work well with Sideblog.

  22. Yoyo Says:

    I don’t use sideblog, but I get the following error using Ver. 1.0.0c on WP 2.0.3:

    WordPress database error: [Not unique table/alias: 'wp_post2cat']
    SELECT DISTINCT * 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_posts.ID = wp_post2cat.post_id) WHERE 1=1 AND post_date_gmt <= '2006-06-17 09:52:59' AND (post_status = "publish" OR post_author = 1 AND post_status != 'draft' AND post_status != 'static') AND post_status != "attachment" 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) AND (category_id = 2) AND (post_end_date >= '2006-06-17 23:59:59' OR post_end_date IS NULL) GROUP BY wp_posts.ID ORDER BY post_date DESC LIMIT 0, 6

    Any ideas what is going on? All I need to do is NOT allow a couple of my categories in the main blog RSS feeds.

  23. Rich Says:

    Yoyo, you’ve got the same problem as JP with Sideblog, something’s combining the calls so you end up with two LEFT JOIN wp_post2cat statements in the join portion of the query.

    It’s probably some other plugin that adds the second LEFT JOIN without checking that one’s already been put into play. (In CatVis we check that before adding the join.)

  24. ZMAng Says:

    Hi, thanks for the great plugin. However, it doesn’t seem to work when multiple categories are assigned to a post (e.g. one removed from index page, while another is not).

    Is there any way so that a post can be removed from the front page as long as one of its categories has been set as invisible?

    Thanks in advance.

  25. Rich Says:

    Alas, this is one major flaw with the visibility issue… one I hope to have time to tackle sometime.

    In fact, there’s more to it than that.

    Some folks, like you, think a post shouldn’t appear if ANY category is set to invisible, and others think it should be visible if ANY category would make it visible.

    I happen to fall in the latter group.

    Suppose you have a post that’s appropriate for “members” and for “evaluators.”

    You’d want it to appear for evaluators even if members was restricted from the home page. Or sidebar list. Or whatever. Well, that’s what I’d think.

    But, as it is, mysql picks one and uses that. So with multiple categories, anything can happen.

    Sorry about that.

  26. Dave Says:

    Brilliant!!!! I’ve been trying to solve this problem for days, was pointed to your plugin and voila. Done in 5 seconds. Peace, Love and Plug-ins!

  27. Keith Allen Says:

    Thank you. This is excellent work and should be referenced on the WP website for plugins. Had to search for a couple of hours and even install the original version before finding this one. I have an “Opinion” catagory, where I like to vent once in a while, but I don’t want to force people to read it when they first hit my page (only if they really want to subject themselves to my point of view).

    Thanks again for all the time you spent developing this and making it available for everyone.

  28. Kelvin Wong Says:

    I am using K2 and widgets plugin for the sidebar and I also have your plugin activated.

    When I click a catergory at the sidebar, I get the following error:

    [Unknown table ‘wp_post2cat’ in on clause]
    SELECT DISTINCT * FROM wp_posts LEFT JOIN wp_catt_visibility ON (wp_post2cat.category_id = wp_catt_visibility.catt_ID) WHERE 1=1 AND post_date_gmt <= ‘2006-06-26 00:57:59′ AND (post_status = “publish” OR post_author = 2 AND post_status != ‘draft’ AND post_status != ’static’) AND post_status != “attachment” AND ((wp_catt_visibility.archives=1 AND wp_catt_visibility.cv_user_level<=10) OR post_status=’static’ OR wp_catt_visibility.catt_ID IS NULL) GROUP BY wp_posts.ID ORDER BY post_date DESC LIMIT 0, 5

    When I turn off your plugin.. everything goes back to normal. Any advise?

    Thanks

  29. Rich Says:

    Kelvin, I think version c will help… download it!

  30. Matthew Wayne Selznick Says:

    Works like a charm! I needed a solution like this… a five second google search, a ten second read of some WP Forum posts, a quick download, a quick install… it took less than five minutes to have a problem, find a solution, install it, and have the problem solved.

    Days like this, I really love the internet — and folks like you, who create plugins and offer them for free to the community. Great job.

  31. Kelvin Wong Says:

    Rich, thanks for the tip, the c version works!

  32. lausse Says:

    there are some issues with David Coppits Category Order (http://www.coppit.org/code/) This will keep on working, whilie his hide all the cats if this is installed.

  33. John Says:

    Just like everyone else said, this solved a problem I had been pulling my hair out about for hours - excluding more than one category from the front page with “query posts” is more difficult than it has to be!

    But this is even better. Thanks!

  34. Rick Says:

    This plugin is great :) But I’m wondering if it’s possible to still show a hidden category in a seperate section of the page ie. I have two loops running, one for a devoted category, dont want to kill it all together.

  35. Marcus Says:

    Great plugin. One minor problem - it doesn’t hide the posts in my sidebar. I have created a “privatetest” post allocated to a “private” category to test and this post doesn’t appear on the home page, but does appear in the sidebar.

    My sidebar code is below:

    Recent Posts

    <ul class="posts">
    <?php BX_get_recent_posts($p,20); ?>
    <A href="http://www.marcuscake.com/sitemap/">View all posts (sitemap)</a>
    </ul>

    I suspect the BX_get_recent_posts function may not be typical.

    The following is from the BX_functions.php file:

    function BX_get_recent_posts($current_id, $limit)
    {
    global $wpdb;
    $posts = $wpdb->get_results(
    "SELECT ID, post_title FROM "
    . $wpdb->posts . " WHERE post_status='publish'
    AND post_category=='17' ORDER BY post_date DESC LIMIT " . $limit);
    foreach ($posts as $post) {
    $post_title = stripslashes($post->post_title);
    $permalink = get_permalink($post->ID);
    if ($post->ID != $current_id) echo "<li><a>" . $post_title . "</a></li>\n";
    }
    }

    Can anyone make any suggestions? Thanks for your help in advance.

  36. hikka10 Says:

    Just as info:
    I also had the conflicet with two LEFT JOIN.
    Did a disable of the plugin ‘Front Page Categories’ (ok plugin, but manual edit in php file).

    Very fine plugin you made here.
    Regards

  37. jonathan Says:

    gracias justo lo que estaba buscando!!

  38. Elena Says:

    Excellent! Worked like a charm. :)

  39. Franco Says:

    I’m using your plugin. But all the posts in the hided category appears in the rss feed, and you can read all that posts with a direct link.

  40. Florian Says:

    Hi,

    I’ve got the same problem. The category is hided, but in the rss feed the post appears-

    is there any fix for that problem?

  41. hadi farnoud Says:

    i have same problem with sideblog, i realy need both (sideblog and catvis) what can i do?

  42. Rich Says:

    Franco and Florian, when I uncheck “Feed” the stories disappear from the RSS feed. If you’re not getting that behavior, it must be due to some other plugin or modification on your system.

    Hadi, sorry, we have no solution here for plugins that don’t use the standard hooks.

  43. Jn Says:

    Woohoo! Worked like a charm! Nothing can describe my relieve now. Heh heh… until it breaks (have not checked the feeds, search, etc.), of course. =P

    Well done!

    • WP 2.0.3
  44. Jn Says:

    Oh, just one problem.

    If some smart alec did something like http://myblog.com/category/private , apparently all the private entries will appear. Any idea?

    Cheers!

  45. Upekshapriya Says:

    Hi Rich

    Just wondering if this Category Visibility plugin can be made to work with Subscribe2 plugin - what I need to happen is the list of categories in the subscription page to be restricted by the level of the user, as would happen anywhere else on the site, but not in the admin panel it seems.

    To be more general - I want to be able to restrict the categories shown to a user even in the admin panel. Is this at all possible?

  46. Rich Says:

    Upekshapriya, you might try editing the source code. As it is, the admin panel gets everything.

    CatVis has never been a “security” feature, actually, more of a “display appropriate material” kind of thing.

    That said, in version c, around line 205, are a couple of lines that you might try commenting out.

  47. Upekshapriya Says:

    Just discovered that neither version seems to be working on a post in a category that’s restricted to user level 10 under a couple of conditions (when logged out completely).

    The post is shown in the sidebar when I list the titles of the latest posts with wp_get_archives(’type=postbypost&limit=5′)

    Using the permalink to the post provided by above condition the post shows fine on its own.

    Thought that might interest you

  48. Upekshapriya Says:

    Rich, sorry I didn’t see you post before I wrote the next one.

    Tried what you suggested in commenting out lines 205 and 206 to no effect. Also commented out 189 which had the same reference. This didn’t work either (ie all these lines were commented out). Maybe it’s a lot more complicated to do it?

  49. Jean Says:

    Hi Rich,

    Oh, I forgot to mention that I was using v1.0.0c that allowed readers to key in the URL http://myblog.org/category/private to read all the posts in what apparently is a private category.

    However, it seems that v1.0.0b didn’t have this problem. When readers tried something like that above, they have a page not found response, which is perfect.

    May I know which is the expected behavior?

    Cheers!

  50. Mario Says:

    Hi Rich,

    Thanks for the plugin. Works very well until I use it with Category Order v1.9.4 by david Coppit. Not only do I need to hide a category from the side bar, but I need to put them in a specific order.

    Andy ideas?

    Best regards!

  51. Zjaak Says:

    Hi, when I exclude certain categories (from the frontpage, archives - everything), I can still see the posts when using the tag “get_archives”. I guess this exclusion only works in the real archives page? Too bad.

  52. Linda K Says:

    Hi there, thanks for the plugin. Very useful, however it behaves strangely when I try to display an unordered indented list of my categories, subcategories and sub-subcategories. The first category displays in bold as intended, however every other category acts as if it is a subcategory of the first one ….
    Tried both versions of the plugin and they both do the same thing ..
    Hope you can help,
    cheers.

  53. Linda K Says:

    Have found a fix for my problem, a bit clunky perhaps, but it works for 2 levels of subcategories:
    At line 322, change the part of the for each statement as follows:

    foreach ($linklist as $link) {
    if(preg_match("/class.children/”, $link)) {
    $children = 1;
    $newlist .= $link;
    } elseif(preg_match(”/class.
    children/”, $link) && ($children=1)) {
    $children = 2;
    $newlist .= $link;
    } elseif(preg_match(”/<\/ul>/”, $link) && ($children=1)) {
    $children = 0;
    $newlist .= $link;
    } elseif(preg_match(”/<\/ul>/”, $link) && ($children=2)) {
    $children = 1;
    $newlist .= $link;
    } else { ….. (ETC)

  54. sven Says:

    wonderful. Definitely try to get this to be a default included feature for wordpress !!

  55. Guillermo Says:

    When I activate the “category order plugins” and “category visibility” the category doesnt appear…
    This could be fixed? Thenks…

  56. Alok Says:

    pretty slick, but wanted to know if I can setup a way in which certain categories show up on certain pages only. For eg. If I have a category called News, can I get it to appear only on the ‘News’ Page? I checked the wordpress forums, but the code wasn’t quite helpful [ noob to php ], so some1 asked me to check out your plugin. Would really appriciate help in any extent possible.

  57. Rich Says:

    Alok,

    No, this won’t do that.

    What you describe, well, that’s what WordPress category pages are, pages which display only posts for the specific category, i.e., yourdomain.com/?cat=5

  58. Nawaaz Says:

    Hi Rich -

    I see that 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. Is this the expected behaviour? I am using wp2.0.3 and I checked both the b and c versions of your plugin.

    Not sure how this happens since the loop in single.php (to display the single post) is similar to the loop in the main index template (if (have_posts()): while (have_posts()): the_post(); … ). Does this mean the filters you are adding to posts_join and posts_where are somehow not being called for the single post?

    Any clarification would be very helpful. Thanks!

  59. Rich Says:

    Yep, Nawaaz,

    It’s not a security plugin, it’s just designed to control what shows up on front page, sidebar, etc.

    You’d be correct in a need to understanding how single posts are called… especially with permalinks.

  60. Guillermo Says:

    Hi Rich, im having a problem with calendar (or archive) links. They give me a “404 not found”, but they work if i deactivate the plugin. Im using the 1.0.0c with permlinks. And i have the right configuration in your plugin (actually, i have the the visibility on for all options).
    What could be happening?

    PD. Sorry for my english :(

  61. Rich Says:

    Guillermo,

    In the sidebar, you’ll see archives listed that have articles, but when you click the link you’ll get a 404 if all the posts for that month are in categories which have archive unchecked.

    Recheck “archive” and the posts should show up.

  62. Guillermo Says:

    …And it works!!! I feel so lame!!! Thank you very much specially for your fast response!!!

  63. Rich Says:

    Guillermo,

    It works, but it’s not ideal. Maybe someday I’ll come across the reason an archive with only invisible category posts shows up in the sidebar. (I’m not using Archives in any of my websites, so it’s never been an issue for me.)

    ‘Til then, don’t feel lame, the plugin is lame in this instance.

  64. Karl Says:

    I noticed that this plugin has a conflict with the Sideblog Wordpress Plugin tht can be found here,

    http://katesgasis.com/2005/10/24/sideblog/

    Just wondering if that could be solved somehow.

  65. GD Says:

    hey rich, im having a problem.. its showing the hidden posts under my blog’s recent posts list on the right side of my page.. so ppl can still acess that post.. how do u get it to not show up on that menu?

  66. Rich Says:

    GD,

    Well, yes, that can be a problem, because WP’s get_posts() function pays no attention to this. I just posted a new version, 1.0.0d, which adds a replacement function, cv_get_posts().

    This may also be the problem others have had with other non-compliant plugins.

    Then you can use a function like this for Recent Posts:


    function ryo_recent_posts($no_posts = 5,
    $before = '<li>', $after = '</li>',
    $skip_posts = 0, $cat = 0) {
    if (function_exists('cv_get_posts')) {
    $posts = cv_get_posts('numberposts='.$no_posts.
    '&offset='.$skip_posts.'&category='.$cat);
    } else {
    $posts = get_posts('numberposts='.$no_posts.
    '&offset='.$skip_posts.'&category='.$cat);
    }
    $output = '';
    if ($posts) {
    foreach ($posts as $post) {
    $post_title = strip_tags(stripslashes($post->post_title));
    $permalink = get_permalink($post->ID);
    $output .= $before . '<a href="' . $permalink .
    '" rel="bookmark" title="Link: ' . $post_title .
    '">' . $post_title . '</a>' . $after . "\n";
    }
    }
    echo $output;
    }

  67. GD Says:

    thanks!

  68. Albertojm Says:

    i have a problem, when i post an entry in two categories (example
    “sports”: normal category, not affected by the plugin.
    “other category”: set up for not showing the entry in the main/front page.

    the entry still appears in the main/front page.
    ¿it’s any way to fix this?

  69. Rich Says:

    Albertojm,

    See my comment of June 17, 2006, above.

  70. Thais Says:

    hi,
    thanks for your plugin!

    there is a way to show how many posts are “visible” in front page after using this plugin?

    (sorry for my terrible english!)
    thais

  71. Rich Says:

    In the loop, you can use count($posts) to get the number.

  72. Thais Says:

    thanks!!

  73. Sven Says:

    hi,

    As said, great plugin. However, having an option to filter hidden posts out of the main page (I know they dont show up directly on main page, but when I click a post on main page, hidden posts are shown as next/previous) - and - to disable direct links to hidden posts would be really nice.
    I know this wasnt supposed to be a security plugin. However, for simple applications (like mine ;) ) these options would make it one.

    I just started a page for a kindergarden, and I simply want some contents to be completely hidden from unregistered/low level users, while I dont want to bother registered users with an additional password entry or even a browser login dialog for secured content.

    Don´t you think, adding the two hide Options “Direct” and “Loop” (or whatever they would be called) would be a welcomed improvement to the plugin?

    Kind Regards,
    Sven

  74. Sven Says:

    Would do add this myself, but, unfortunately I haven´t the slightest knowledge in php right now (might change sometime ;-) )

    Regards again,
    Sven

  75. TedFox Says:

    I know this is a little advanced.

    but testing this plugin with wordpress 2.1, when a post has multiple categories, it’ll appear in the loop multiple times.

    for e.g. if a post has 3 categories, it’ll appear 3 times in a loop

    Any suggestions on where I should be looking to solve the problem?

  76. Rich Says:

    I don’t have that problem in 2.0.4.

    Multiple categories ARE a problem, however.

    The first challenge is deciding what you want it to do.

    - Show ‘em if ANY category is visible.

    - Don’t show ‘em if ANY category is blocked.

    Frankly, there are contradictory, yet logical and valid, answers.

    Then comes the challenge with getting the code to work.

    See comment by ZMang and my response on June 17.

  77. Luc Feenstra Says:

    ok i downloaded this plugin,i got the category not to show on home but how do i get it so it shows on another page?

  78. Greg Says:

    Thanks for the great plug-in. Just what I needed.

  79. visaap Says:

    Like Luc I’ve got the same thing. All my categories that have private posts in them won’t appear in de wp_list_cats I would like to trigger my vistors on subscribing by showing them all the categories I have. As soon as they open the categorie (with private posts in it) the will be confronted with the log in/register page.
    How do we un-hide the categories?

    P.S.: It is a great plug-in!

  80. Dave Says:

    Great Plugin, just what I’ve been looking for.

    I’m using it to filter the monthly archives down to showing the contents of just one category: however, there’s some functionality I’m not sure how to implement here.

    Imagine I’m filtering to just show category A, and my site has two categories, A and B.

    If I post in december to category A and category B, and in january post only to catogory B, my monthly archive list shows as:

    DECEMBER
    JANUARY

    even though, with category B filtered out, it should show

    DECEMBER

    only, as January’s posts are all in the filtered category B. However, the standard wordpress call of wp_get_archives() doesn’t care. Does anyone have any idea of a workaround for this?

  81. A Pseudo-Tutorial On Inline Asides | Open Switch Says:

    […] As a last step I wanted to remove the “asides” category from showing up in my feed. I did this for several reasons but mostly because it’s what Kottke does and darn it, I wanted to do it too. Instead of more hacking — which I was tired of at this point — I just found a nice simple plugin and let it do the work for me. […]

  82. Danny Castillo Says:

    I downloaded the lastest version. I this error with 1.0.0b also.

    WordPress database error: [Not unique table/alias: ‘dc_post2cat’]
    SELECT DISTINCT * FROM dc_posts LEFT JOIN dc_post2cat ON (dc_posts.ID = dc_post2cat.post_id) LEFT JOIN dc_catt_visibility ON (dc_post2cat.category_id = dc_catt_visibility.catt_ID) LEFT JOIN dc_post2cat ON ( dc_posts.ID = dc_post2cat.post_id) WHERE 1=1 AND post_date_gmt <= ‘2006-11-07 04:22:59′ AND (post_status = “publish” OR post_author = 1 AND post_status != ‘draft’ AND post_status != ’static’) AND post_status != “attachment” AND ((dc_catt_visibility.front=1 AND dc_catt_visibility.cv_user_level<=10) OR post_status=’static’ OR dc_catt_visibility.catt_ID IS NULL) GROUP BY dc_posts.ID ORDER BY post_date DESC LIMIT 0, 10

    I am not sure whats happening. any help would be get. Thanks

  83. Rich Says:

    Danny,

    You’re getting two LEFT JOIN dc_post2cat statements which means you’re using another plugin that doesn’t protect against that occuring.

    CatVis is running first and adding the needed phrase, then the other plugin is running and adding a dc_post2cat join also.

    CatVis checks for this conflict before adding the join to the join phrase, but it can’t keep another plugin from adding it later.

    Try turning off other plugins, one at a time, to catch the culprit.

  84. Rupen Says:

    Hey there,

    I downloaded the plug-in, but I seem to be having issues. As soon as I activate the plug-in, all my categories disappear from the sidebar. This is the code on the sidebar to call the categories:

    Categories

    As soon as the plugin is activated.. BAM.. that gets removed even though all the boxes are checked and user level = 0

  85. Rich Says:

    Rupen,

    Change the code in the sidebar to read

    wp_list_cats('sort_column=name');

  86. Ralf Says:

    This is a very usefull plugin. Thanks for sharing it. I would have one wish, though: Could you please modify the plugin to show the names of the roles (subscriber, editor, admin, custom roles made with RoleManager) instead of numeric levels?

    I guess - without studying code - that the fact that several role names can be assigned to the same numeric id might lead to the need of more extensive changes… but I am just looking for a nicer user experience, so perheaps substituting a role name list for the id would be sufficient…

  87. Rich Says:

    Ralf,

    The role names, with associated numbers, are shown at the bottom of the Category Visibility management page, just above the “Submit Changes” button.

  88. Moshav HaAm Lab » Blog Archive » WordPress Category Visability Hack Says:

    […] Rich Hamilton’s revision of Keith McDuffee’s original “Category Visability” is an excellent WP plug-in. It just doesn’t quite work the way I needed for the main Moshav HaAm site, which has relatively sophisticated needs for layers of content access, given our mandate to be as open as possible to a number of different valences of community and leadership. […]

  89. Giofilo Says:

    Hi, I have activated the plugin, but it give me a problem. In the home page there is this text:

    Catchable fatal error: Object of class wpdb could
    not be converted to string in
    C:\wamp\www\giofilo.com\wordpress\wp-content\plugins\category_vis-rh.php
    on line 212

    Sorry for my bad english,
    Thanks

  90. Joel Rothschild Says:

    First, thanks to Rich for a great plug-in! I can’t tell you how much easier it has made an otherwise difficult week.

    Second, for those who (like myself) need different logic for the case of multiple-category posts, I have a working hack of Rich’s plug-in here. I reworked the database implementation so that a post will now be invisible if any of its associated categories are invisible for the current user. I also added the option of hiding posts from single-page view, and I made minimum user-level settings specific to each display area for a category rather than general to the entire category.

    Use my version at your own risk. I’m using it in one project that is still in development. So far so good, but I’m no expert at WordPress architecture and I haven’t tested it very rigorously yet. If you do use it, please share your experiences with me. I suppose I most need to know whether it breaks; though it’s always more fun to hear about how it made your day brighter, teeth whiter, and children smarter. %)

  91. Giofilo Says:

    What I have to do for resolve this problem?

  92. Rupen Says:

    Okay,

    This is an AWESOME plug-in, but I am still an amateur in this whole thing. I am using category templates and I am implementing specific sidebars. I am having trouble coming up with a code to list the parent Category 12 with the children of that same category.

    Any recommendations?!

  93. gerld Says:

    ive tried this and when i click on a single post, using the previous and next links, it still allows me to see the category that i’ve marked hidden.

    any ideas??

  94. gerld Says:

    also, is there any workaround to show the hidden category on other sections of the site?

    this whole wordpress category thing is really driving me insane. do you have any ideas on displaying the hidden category on a sidebar or something? ive tried this, but it doesnt work (i just get a blank page.. meaning php error?)

    <ul>
    <li><a></a> --- </li>
    </ul>

  95. Chin Says:

    Nice plugin, but it have some bug. If user will put url to browser by hand, he can see hidden post.
    For example - visit my site page http://chingiz.org/archives/15
    You can’t find this page from main or others menu, but if you will see to the numbers of public topics, you can find some numbers of hidden post.
    If you plase that numbers after /archives/ - you’ll see “secret” post. At this time i hide content from hiddeh posts by other plugin :(
    Headers of hidden posts anyway can see anybody.
    Please, correct this. And then your plug-in will be the best for hidden zones and posts in WP blogs :)

  96. Chin Says:

    Hey, guyz, i see Joel Rothschild did what i want for upgrade this plugin. Nice work! Single pages now are really invisible! It’s working.
    Thank’s for Rich and Joel Rothschild :)

  97. L Says:

    how does the cv_get_posts() works? im using the function i tried to replaced it with cv_get_posts but it tells me is missing arguement error?

    Thanks in advance

  98. L Says:

    Oops sorry for the incomplete question.

    How does the cv_get_posts() works? im using the function

    get_archives('postbypost', 12);

    i tried to replaced it with cv_get_posts but it tells me is missing arguement error?

  99. Rich Says:

    L,

    cv_get_posts() is similar to the WordPress template tag get_posts() function except that when a category is not passed, it returns posts in visible categories only.

    It would not be a replacement for get_archives().

    You can check get_posts() at

    http://codex.wordpress.org/Template_Tags/get_posts

    The visibleto argument is added, defaulting to list

  100. Erum Says:

    Hi,

    Great plugin. Exactly what I needed! Thanx so much!

    There is one thing I noticed…when I unclick archives for say Category C. Now it disappears off the archives and the front page which is great. However, when I go directly to the category page, it doesn’t show any posts either. Seems like the posts just disappear. As soon as I click Archives back on, the category C page starts showing the categories again.

    Am I doing something wrong?

  101. Ayerst Says:

    Great Plugin, worked like a charm.

  102. Rich Says:

    Erum,

    You’re not doing anything wrong. Category pages are treated the same as archive pages by this plugin.

    While that doesn’t affect me like it does you, it’s not ideal, so maybe I’ll do something about that next time I update.

    You could go about line 253 and comment out the lines that read:

    elseif (is_category())
    $where .= " AND (($cat_visibility.archives=1 AND $lc";

    To comment these out just add // at the beginning of each line.

    That should work by allowing category posts to appear on category pages.

  103. Mike Murray Says:

    Bear with me.

    I am combining three Blogger blogs and a LiveJournal into one WordPress blog on my website. I assigned the two subsidiary Blogger blogs as categories in the WordPress blog.

    I want to present a peek into each of the original blogs on my homepage which I was able to accomplish with “feed2js”. However, after changing feed visibility on the two subsidiary categories, they disappeared not only from the main RSS feed, but apparently there is no category feed as well.

    Does eliminating visibility of a category removed it from all feeds or is it only supposed to eliminate it from the main feed?

    I can work around my problem, but I’d rather not if I can avoid it.

    Thanks for a great tool.

    Ciao for now!
    Mike

  104. Rich Says:

    Mike Murray,

    The test is

    if (is_feed())

    so I’d expect it to remove posts from all feeds.

  105. L Says:

    i dont know what happened, i didnt touch anything i woke up today trying to access my blog and i get this error messaGE?
    Catchable fatal error: Object of class wpdb could not be converted to string in

    /home/atomicb/public_html/l/wp-content/plugins/category_vis-rh/category_vis-rh.php

    on line 212

  106. L Says:

    nevermind, fixed it!
    1. $cats=$table_prefix.’post2cat’;
    2. //$cats=$wpdb.’post2cat’;

    just uncommented the first 1 and commented the 2nd

  107. Xephor Says:

    Thanks a lot - great plugin!

  108. Pipedreamergrey Says:

    Thanks, this plug-in works great! Actually, it’s more than I needed. It’s given me a couple ideas to improve my site.

    Using this plug-in I’m adding advertising and notices about content found only on my site to my feed and notices about content only found in the feed to the site! Kind of cross-marketing to ensure maximum traffic.

    Thanks

  109. Plugbr » Blog Archive » Plugin para controle de categorias na página principal Says:

    […] Já tinha procurado por um plugin que não permitisse que os posts de algumas categorias do blog apareçam na página principal, e hoje encontrei este aqui, não sei se é a melhor opção mas veio em boa hora. Ele controla o aparecimento dos posts de uma determinada [/tag]categoria[/tag] na página principal, o aparecimento da categoria no sidebar, o aparecimento em resultados de busca e alimentação RSS, além de outros. […]

  110. Pipedreamergrey Says:

    P.S. Did anyone ever figure out how to get this plug-in to work with David Coppit’s Category Order plug-in(http://www.coppit.org/code/)? Coppit’s plug-in let’s you indent categories so that they appear hierarchical, but when both your plug-in and Coppit’s are installed categories disappear all together.

  111. Julie Says:

    HI!!! :)

    I recently downloaded your plugin today; however I am having problems with it. When I go to ‘Manage’ I don’t see any “Catagory Visibility” in my Wordpress. Ever since I downloaded Keith’s catagory visibility, I can’t see anything (concerning this plugin/or something similar to it) in my “Manage” area with my wordpress. Has anyone else had this problem? Any help or feedback would be appreciated!

  112. Alberto Says:

    What I want to do on my blog, is every few hours take the oldest post and move it to the
    front of the queue, all automatically. Anyone know if there is a plugin that can do this or
    a simple way to set up another plugin to do this (use my own feed perhaps)?
    Thanks.

  113. Rich Says:

    Alberto,

    See the Oldest2Newest plugin at: ryowebsite.com/wp-plugins

  114. Gary O Says:

    Rich, Have you updated the plugin to display sub-categories correctly? I tried the hack posted by Linda K (19 August) but it brings up the following error:

    Parse error: parse error, unexpected T_CLASS in D:\Domains\go.id.au\wwwroot\wp-content\plugins\category_vis-rh.php on line 339

    Line 339 is

    } elseif(preg_match(”/class.children/”, $link) && ($children=1)) {

    Any suggestions?

    Gary O

  115. Rich Says:

    Well, Gary O,

    I was happy Linda K was able to solve her problem, because it works great on my websites. Displays categories and subcategories just fine.

    And I can’t vouch for her hack.

    It must have something to do with the theme or other plugins that she and you are using.

  116. Alex Says:

    Hi,

    I am not a technical person, so I am afraid to install this plug-in if it does not do what I need. So here is my question. What if I don’t need to hide categories, rather, I just want certain posts to bypass the home page and go directly to a category. Can it do that?

    Thanks!

  117. Alex Says:

    Hi,

    I think I figured it out. I installed it on my test blog and if I only uncheck “front”, the post goes directly to a category bypassing the front page. My question is, could this be considered “cloaking” by Google and other search engines?

    Sometimes I actually do need for a post for that same category to appear on the home page. I display 10 posts on the home page.

    For example, I posted something for that category a few days ago and it is still on the home page, now I need a new post to go directly to that category bypassing the home page.

    If I uncheck “front”, that post (which was posted a few days ago and still on the home page) disappears.

    Is there a work around? Thanks!

  118. Useful Plugins For Wordpress! at sgknox.com Says:

    […] Category Visibility-RH Rev Alter the visibility settings for categories, for WordPress 2.0. Based on an earlier Category Visibility by Keith McDuffee. By Rich Hamilton. […]

  119. Oliver Says:

    Ive been so happy yesterday to find this plugin. Now I found a little problem that perhaps might be solved very easy. Dont know.

    There is a blog (not mine) where I installed your plugin to make only one special category unvisible. The mission was to write articles to be shown only on the home page so that the owner of the blog would be able to edit his home page whenever he likes.

    Works fine. But today I had a look into the RSS archives page where all categories using wp_list_cats(’…&feed=RSS’); didn`t show up anymore. Everything is possible with wp_list_cats but not the feed option.
    Just found out that the plugin shot the whole category list to hell… ;-)

    Would you please give me a hint how to fix that?

  120. Trip Alexander Says:

    Building a site based on WP for a client and love the idea of your plugin. Theoretically does exactly what I need. However when I activate it, I get the following error. Thoughts on what is wrong. I am only an intermediate user of PHP and extermely new to WordPress. Any help would be appreciated.

    WordPress database error: [Not unique table/alias: ‘wp_post2cat’]
    SELECT DISTINCT * 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_posts.ID = wp_post2cat.post_id) WHERE 1=1 AND post_date_gmt <= ‘2006-12-20 00:42:59′ AND (post_status = “publish” OR post_author = 1 AND post_status != ‘draft’ AND post_status != ’static’) AND post_status != “attachment” 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) AND category_id NOT IN (2) GROUP BY wp_posts.ID ORDER BY post_date DESC LIMIT 0, 10

  121. Trip Alexander Says:

    Nevermind. Another Plugin was conflicting with it. After five looks through the other posts I found a similar issue with your response.

    Thanks,

  122. Zendemic Says:

    Hi There,

    Great plugin you’ve developed here - I noticed that it doesn’t work with David Coppit’s “Category Order” plugin. I’m wondering if there are any other Category Order plugins that might be compatible?

    Cheers,
    Peter

  123. Sebastian Says:

    Thank you.

  124. Stephan Says:

    Thanks… that’s exactly what I need. You’re the man.

  125. Shane Says:

    Hi,

    Great plugin, thank you. One question. When I uncheck “Archives” box, and I access the hidden category directly, I get 404 error. It seems it does not fully hide a category if the posts in it are visible in archives.

    Is this a bug?

    Thank you. Shane.

  126. Mandy Says:

    Hi thank you for the plugin. Works so easy it was a snap to plug it right in. :)

  127. bk Says:

    This plug-in works great, thanks!

  128. Zhe Says:

    I installed the plugin, however I keep getting this message

    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 ‘ front=1, list=1, search=1, feed=1, archives=1, user_level=0′ at line 1]
    REPLACE INTO wp_cat_visibility SET cat_ID=, front=1, list=1, search=1, feed=1, archives=1, user_level=0

    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 ‘LIMIT 1′ at line 1]
    SELECT * FROM wp_cat_visibility WHERE cat_ID= LIMIT 1

    and what does mean??

  129. fs Says:

    Hey, I really like your plugin, but it conflicts with Sideblog Plugin v3.0. (I left a comment on the page for that plugin too.) I’m currently have yours deactivated, but if you want the error message I was getting or anything, let me know.

  130. Johan Says:

    Nice, I’ve tried several ways to accomplish this, and your solution is the first one that works. Excellent.

    A question, though, is there some way to remove the category from the post too? That is, if I assign a post to two categories, one of which has all options unchecked, the hidden category is still displayed on the post (like “Posted on Jan 3, 2006 in: VisualCat, HiddenCat”).

    So perhaps there should be another option to check/uncheck, because there might be situations when you want to make a category completely invisible to visitors.

  131. Rich Says:

    Shane,

    Maybe it is a bug. I get a variety of reports regarding the “archive” setting. Some happy, some not.

    Zhe,

    Looks like you’re having problems with Keith McDuffee’s version, not ours.

    fs,

    Yes, there can be conflicts. Sorry, we’re happy to share what we’ve done but we can’t fix conflicts. I guess you’ll have to choose, or reprogram yourself.

    Johan,

    Multiple categories are a challenge in more ways than one. I’ve looked at this before, and, because of caching and the way hooks are designed in WordPress, I didn’t identify a clean way to filter this.

    In my sites, I just leave out the call to the_category(), so NO category hooks are displayed.

    A lame workaround, I know.

  132. notausgang Says:

    many thanks for the lean solution of a whole set of structural problems of my site.

  133. Graeme Says:

    Hey guys im not sure if your aware but there are some compatibility problems with Wordpress 2.1. Ive been using the category Visibility for the last couple of months and upgraded to wordpress 2.1 this morning. For some reason the sub catagories arent hidden, only the text is hidden from the page. Take a look at my page www.graemechidgey.com and you can see on the footer and what i mean! its just a shame as the plugin is great!

    cheers

    Graeme

  134. BigBerries Says:

    ^ Yup. Totally wicked plugin. Totally craptastic with WordPress 2.1. We’re really hoping you this plugin comes back to life for “Ella” because it rules!!!

  135. Talking Out Of Turn » Pain Says:

    […] Update 2: Not only does this version of Category Visibility work, it actually handles the number of posts on the front page better. We appear to have made it through a major upgrade without a loss in functionality! […]

  136. lausse Says:

    Also longing for an 2.1 compatible version.

  137. BigBerries Says:

    We’re going to test the beta as soon as possible but there’s an issue right now with trying to rollback to 2.0.7 from 2.1. Almost as if you “can’t” go back if you upgrade. I’m sure that’s not the case and something is just being overlooked.

    Thanks for the fast response. Be back later to let you know how it goes…

  138. lausse Says:

    As said - at least for me that newest beta feaked the Manage page out. Only shows:

    Catchable fatal error: Object of class wpdb could not be converted to string in /home/snfskane/public_html/wp-content/plugins/category_vis-rh.php

  139. mike Says:

    Your archive of catvis 2.1b2 appears to contain v1.1b1 (beta 1), which unfortunately causes an SQL error on WP 2.1. Is this the correct file?

  140. Rich Says:

    Still working on the 2.1 version… thanks for the feedback.

  141. lausse Says:

    I still (1.1.b3 [beta 3]
    ) get warningmessages when I enter manage in the admin area:

    Catchable fatal error: Object of class wpdb could not be converted to string in /home/mypage/public_html/wp-content/plugins/category_vis-rh.php on line 242

    And that line is following
    $cats=$wpdb.’post2cat’;

  142. thinker Says:

    (beta3) On 2.1, it’s blocking the category listing on the sidebar, but in themes that also list the number of posts within that category, it still lists the number, although it does also omit the link. This may very well be somthing I just need to change in the theme.

    Unfortunately, it also hides the category in the admin section: in the drop-down box for identifying the parent category of a new category (when it’s set to hide front, list and feed). Here it works too well.

    That averages out to working, right? ;)

    It’s definitely progressing. Thank you for your work. I look forward to the fruits of your labor.

  143. Tapanez Says:

    I was using Gudlyf version until upgrading WordPress to 2.1 this morning, database errors appeared. Have installed your plugin with no errors but I’ve some categories checked as not appearing on front page but it isn’t working, for example my “chorradas” one.

    Suggestions?

    Thank you for your work!

  144. Michael Hinz Says:

    The “Object of class wpdb could not be converted to string” error can be easily fixed by replacing $wpdb in that line with $wpdb->prefix

  145. Rich Says:

    lausse,

    I had you try running it with that line commented out (it’s no longer needed)… and it worked, so I’ll post that version as beta 4.

    thinker,

    I’ll try to reproduce the category list thing. Can you verify what function your theme calls to produce the list?

    With beta 3 I changed the method used to detect admin pages… it should now be returning an unchanged where clause, but in beta 4 I’ll try a slightly different approach.

    Tapanez,

    I looked at your website and the “chorradas” category was appearing in the sidebar, but did not seem to be showing up on the front page. To stop that uncheck chorradas for “List.” “List” applies to the sidebar type lists of categories. (So I don’t think that’s a plugin error.)

    Michael Hinz,

    You are exactly right, though it’s an unneeded line, removed in beta 4.

    All,

    You may have noticed that the new version is handling posts which are posted in multiple categories better… if ANY category is marked visible, the post appears. (Before it picked the first category mySql found.)

    The logic here is that if you put it in a category that is visible, you aren’t wanting to hide it.

    I’m uploading beta 4 for testing… although it has only a few adjustments, removing the unneeded line and another approach to admin panel tests. I really appreciate your feedback! Thanks!

  146. André S. Says:

    Hi,
    the problem with listing the number of posts without the category shown in WP 2.1.

    Default theme uses:

    wp_list_categories('show_count=1&title_li=Categories');

    This produces:

    <a href="http://link/to/category" title="View all posts filed under category" rel="nofollow"></a> (1)

    There is indeed no text between the <a>-tags.</a>

    The catecory is not visible, the count is.
    Older themes use

    wp_list_cats('sort_column=name&optioncount=1&hierarchical=0');

    which produces the same output.

    Best Regards and thanks for this plugin,

    André

  147. Graeme Says:

    Hello ive downloaded beta 4, the children is still not hidden, does anyone know if there is a way to do a CSS hack as a temporary measure to hide children catagories? apparently there are some issues with wp_list_categories, on the Wordpress forums some say this will be sorted out in the next version.

    Graeme

  148. love Says:

    Hello
    i install youy plugin in last version wordpress
    after activation it say this error in home page:

    Catchable fatal error: Object of class wpdb
    could not be converted to string in
    /home/lover/public_html/wp-content/plugins/category_vis-rh.php
    on line 212

    Please tell me what is my problem & how can i fix this problem
    thank you

  149. Graeme Says:

    Hey ive kind of found a way to remove the un-selected Children catagories. In your Css paste
    }
    .children {
    display: none
    }

    and this will remove the Children blank subcatagories. This will not remove the un-selected parent catagories though. Thanks for the update Rich!

    Cheers

  150. André S. Says:

    wow, that was fast :) .

    Works perfectly. Thanks again.

  151. Wayde Christie Says:

    @love

    I had the same error.

    I took at a look at the code and noticed these 2 lines around line 242:

    //$cats=$table_prefix.'post2cat';
    $cats=$wpdb.'post2cat';

    If you swap the comment to this:

    $cats=$table_prefix.'post2cat';
    //$cats=$wpdb.'post2cat';

    it works!

  152. Rich Says:

    André,

    Thanks to you, your clue put me onto it.

    Graeme,

    I think the children issue is a WordPress issue, not catvis. Check here: http://ericulous.com/?p=93

    I use Fold Category List plugin, and it seems to work as advertised.

    love,

    Try the beta version.

  153. thinker Says:

    Other stuff works great now (woohoo! thanks)

    I use the stock template for admin files…

    Line 38 of wp_admin/edit-category-form.php calls the dropdown for choosing the category parent:
    category_parent . ‘&hierarchical=1&show_option_none=’ . __(’None’)); ?>

    Hope this helps. I certainly wouldn’t make it a priority as I doubt I’ll be using children of hidden categories, but the additional blank line jumped out at me and I considered how awkward it would be to want to set a child of one hidden category if you had more than one blank line to choose from.

    I am impressed by your speedy work. Thanks again.

  154. Russ Adams Says:

    This is a very nice plugin, but it left the bullet and an empty place where the category would have shown.

  155. Dating Sage Says:

    I having the same problem as Russ Adams. Is there a fix for that issue?

  156. Rich Says:

    Russ Adams, and Dating Sage,

    In order to help, I need more info…

    Are you using the latest beta?

    Are you talking sidebar? What function is getting called in your sidebar?

    What version of WordPress are you using?

  157. Jeff Says:

    I’m having the Same issue as dating sage and russ adams. I’m using the latest beta (5) with Wordpress 2.1. Everything else works perfectly thus far, but I need the category listing.

  158. Breeze Says:

    When I need it, I found you! Thanks!

  159. Ayerst Says:

    Rich, I am using the newest version of WP.

    I love the Cat Visibility Plugin and it works swimmingly with all other plugins in WP 2.05,6 and 7.

    However in 2.1 I get this sql 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 ‘(SELECT post_id FROM wp_post2cat LEFT JOIN wp_catt_visibili]
    SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts LEFT JOIN wp_post2cat ON (wp_posts.ID = wp_post2cat.post_id) WHERE 1=1 AND category_id IN (6, 4, 7, 8) AND (post_type = ‘post’ AND (post_status = ‘publish’ OR post_status = ‘private’)) AND ID = ANY (SELECT post_id FROM wp_post2cat LEFT JOIN wp_catt_visibility ON (wp_post2cat.category_id = wp_catt_visibility.catt_ID) WHERE ((wp_catt_visibility.cv_user_level<=10) OR post_status=’static’ OR wp_catt_visibility.catt_ID IS NULL)) GROUP BY wp_posts.ID ORDER BY post_date DESC LIMIT 0, 7″

    I am uncertain what this means (still learning Dbases.)

  160. Dating Sage Says:

    I am using beta 5. I am talking about the side bar. I am not sure how to tell which function is getting called. You can view the site by clicking on my name. I am running 2.1.

  161. BRA5iL Says:

    Since WP 2.1 the method cv_get_posts(’numberposts=5′) keeps listing pages as well??

    Is there a way to prevent this?

    Thank you…

  162. Paul Oyler Says:

    I just installed beta 5 on a new site running WP 2.1

    I think it is working fine, I just want to check on a behavior - if I am logged in as the admin, am I supposed to still see the chosen category on the front page? I thought that the plugin was not working at all until I checked the site on a different browser (on which I was not logged in) and all of the posts in the chosen category were NOT visible. When I am logged in, they ARE visible. Is this the correct behavior?

  163. Michael Says:

    beta5 works well except the posts still show up on the home page of my blog. I’m not sure if that is on purpose but I was expecting them to be hidden.

    thanks!

  164. Markus Says:

    Hi, i´m not sure, but i think i found a bug: i have a category-list wiht 3 level. with your plugin, the list has a failing: after level 3 is level 1 list in level 2 and not in level 1. understand you? try it with

        <?php wp_list_cats('hide_empty=0&hierarchical=1'); ?>
    

    list is ok without your plugin. but activte i your plugin, list has a failing.

    can you fix it?
    thank´s for your work!
    markus (sorry for my terrible english!)

  165. BRA5iL Says:

    I managed to patch the issue with the appearing pages on cv_get_posts()

    @line 479 I added “AND post_type=’post’ ”
    to the SQL…

    Maybe you can fix it or provide a switch. Afaik the original get_posts() does NOT bring up pages…

  166. weasel Says:

    I tried out your plugin and it’s great! Beta5 and it runs fine on my 2.1 WP install.

    One little glitch, can’t really blame you for it - after setting up the permissions, I went and changed a few category names and descriptions. I had to change/re-save all the permissions in your plugin for it to “see” the new categories, despite the status being listed correctly on your plugin page.

    E-Mail me for details. =)

  167. weasel Says:

    Oh hey just found another bug (may be related to the one listed previous) - If I’m in the admin panel, and I hit the “view site” button and it takes me back to the main page with a clean URL

    thedailyblitz.org/

    My categories posted as “not visible on the front page” are indeed visible. If I hit refresh they all go away. Any idea what’s causing that?

  168. Joe Says:

    It’s not often you see this level of control in a plugin. That’s awesome. Great job.

    I’m using the plugin for the first time with WP 2.1 and beta5. As some others have mentioned (and I haven’t seen an answer but I could have missed it) I’m having the problem where Months/years are showing up in my archive listing that contain posts that are in categories that I have set to be hidden. Is there a work-around for this so that if there are only hidden posts in a given month then it won’t show the month name under the Archives heading?

    Thanks!

  169. ALV Says:

    cat-vis is one of the best plugins and it’s really great that someone feels responsible for keeping it running :-) Thank you, Rich. I just upgraded our blog to WP 2.1 and installed the beta version of cat-vis. Hitting the “search”-button I received the same error msg Ayerst did. Did someone find already a solution? Unfortunately it’s not connected to the php version (we use 4.3.10-16). It would be great to get some help! Thank you!

  170. maddagu Says:

    […] that’s such a handy plugin. first i had a separate blog for my photos and now thanks to that… all in one. just tell it wich category you don’t want to see on the frontpage and off you go. make a separate link for the category. ready. easy. here is the link socialize […]

  171. sayed Says:

    I’m getting the same message as Ayerst and ALV. Any ideas?

    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 ‘(SELECT post_id FROM wp_post2cat LEFT JOIN wp_catt_visibili]
    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 ID = ANY (SELECT post_id FROM wp_post2cat LEFT JOIN wp_catt_visibility ON (wp_post2cat.category_id = wp_catt_visibility.catt_ID) WHERE ((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, 5

  172. Wayde Christie Says:

    If I click my Edit page link whilst viewing the blog then save I get this error:

    WordPress database error: [Unknown column ‘category_id’ in ‘where clause’]
    SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND category_id IN (8) AND (post_type = ‘post’ AND (post_status = ‘publish’ OR post_status = ‘private’)) GROUP BY wp_posts.ID ORDER BY post_date DESC

    This error then disappears as soon as i refresh the page.

    Any ideas?

  173. Bill C. Says:

    Works for me. Thanks for updating. :D

  174. Tommy Miles Says:

    A wonderful plugin! Absolutely CRUCIAL if you’re trying to do anything at all complicated.

    I’m more used to Drupal, so trying to get clever with Categories drove me up a wall for two days!

    This should really be part of any base installation of Wordpress.

  175. Alen Says:

    Hi, I have recently moved to WP 2.1 and downloaded your latest version of the plugin. Beside the fact that it does a great job for me, it creates one little problem! Posts are listed multiple times if they are assigned to multiple categories. 3 categories, 3 times… etc.
    They are not multi-listed on the category template but in the single template and RSS feed!?!

    I know that cat-vis creates this problem, since it does not exist when I deactivate the plugin.

    Is anyone familiar with this?

  176. Mal Says:

    I have the latest version of the plugin (2.1beta5) running on my development site which is here:
    http://www.stippy.com/wp_dev/

    The plugin is active, and is set not to show the “japan-language/english-word-of-the-day” sub category anywhere. But, as you can see, it is displayed on the front page of the site (about the 4th post down, Title is “E-WOTD: Cuckold”).

    Any other info that I should provide? I love this plugin, but it is really not working in my site with wp2.1.

  177. Jauco Says:

    I have a mysql server 4.0 running, so I get the error in query (like some other people commenting). I believe the subqueries where added to fix a problem with posts who have multiple categories. As it happens, the post I’m trying to hide doesn’t have double categories. Could you republish a version of your 2.1 compatible plugin with the old query?

  178. TIGOS Says:

    When we will have an update of this plugin for Wordpress 2.1?<