I recently got an e-mail from a reader wanting to know how to hide their sub-categories in WordPress. If you use WordPress 2.1 or newer, this is actually really easy to do.

All you need to do is open your stylesheet and add the following anywhere:

.children {
display:none;
}

You can also style the children accordingly this way if you’d like!

Kyle Eslick is WordPress enthusiast who took his passion for WordPress to the next level in 2007 by launching WPHacks.com as a place to share hacks, tutorials, etc. Connect with Kyle on Twitter or Google+!

  • http://www.garryconn.com Garry Conn

    Kyle,

    That is a pretty common and neat little CSS trick. Unfortunately doing something like that could cost you a “good standing order” with Google and other search engines.

    You might want to consider explaining this in your post so that you’re not misleading people who would rather not endure a ranking penalty.

    Source: Google Webmaster Guidelines – Hidden Text and Links.

    Not busting your chops, I just think that you might not have considered this as being something harmful for your readers.

    Best Regards,
    Garry Conn

  • Pingback: Le ultime notizie più succulente dal mondo dei blog - Edizione del 27 febbraio 2008 | MondoBlog

  • http://kyleeslick.com Kyle Eslick

    @ Garry – I appreciate your concern; however, it is important to note that sub-categories are internal links, rather than linking out to another website.

    In addition to usually not being indexed due to the Robots.txt settings on most WordPress blogs (this is done by default for All-in-One SEO Pack users), passing internal link juice behaves differently than passing link juice to other websites. As a result, it does not seem to me that this would be a violation of Google’s guidelines. All you are really doing is promoting your internal pages, which is something standard that webmasters do to emphasize certain posts/pages.

    From what I can tell in reading through their guidelines, Google’s concern is with people hiding external links, not internal links.

    Another option for a WordPress user is to, of course, not create any “children.” Just treat all categories as “adults.”

  • http://www.garryconn.com Garry Conn

    Kyle said, “I appreciate your concern; however, it is important to note that sub-categories are internal links, rather than linking out to another website.”

    Kyle, come on man… do you really think that I don’t know the difference between an external link and an internal link?

    Kye said, “passing internal link juice behaves differently than passing link juice to other websites. As a result, it does not seem to me that this would be a violation of Google’s guidelines.”

    Ok, let me get this straight, you believe that Google has two or more different kinds of PageRank? Specifically, there is an independent PageRank system just for internal links alone?

    I am not buying that. I see no official documentation on Google regarding that, nor do I see anywhere written where it says, “Don’t hide external text links, but please by all means, have a field day and hide all your internal links! The staff at Google work hard towards creating TWO PageRank Systems for webmasters and publishers who want to exploit everything we say not to do but do so internally.”

    I wasn’t going to make a stink about this, but when you shoot my comment down, which I must mention again, I am just trying to help, it some what disappoints me.

    Your post is misleading. Anyone that uses CSS to style your links (internal or external) to cause them to be hidden run the risk of paying a ranking price in the major search engines.

    Wouldn’t it be a better solution to use the WordPress supported Include or Exclude Category Template Tag.

    Like I said in my first comment. I am not busting your chops, I just feel that your post is misleading. I am not one to just rant and rave and leave. If you look at the above reference, you’ll see that the solution I am presenting does what you want and does what I want combined. It has the ability to hide any category or sub category the publisher wants hidden and it doesn’t write the link code on the pages.

  • http://www.cybercoder.net David Cooley

    Not sure why PageRank was mentioned in these comments, PageRank has nothing to do with it.

    “If your site is perceived to contain hidden text and links that are deceptive in intent, your site may be removed from the Google index”

    I have seen it done, if you hide ANYTHING, text or links, your site can (and probably will) be dropped from the Index.

  • http://www.garryconn.com Garry Conn

    David Said, “Not sure why PageRank was mentioned in these comments, PageRank has nothing to do with it.”

    Yeah no doubt… I didn’t mean to expand on that but I felt like that part of the comment needed to be addressed as well.

    David is totally right. PageRank or any ranking systems used by the major search engines are totally not the issue at hand. This is a issue that can cost you a free gift of having your website listed in very popular search engines.

  • Pingback: Blogosfera: Le Ultime Notizie - Edizione del 27 febbraio 2008 | MondoBlog

  • Pingback: Collection of WordPress Hacks

  • Pingback: 100+ Killer Wordpress Resources | Steffan Antonas' Blog

  • Pingback: Collection of WordPress Hacks | WordPress Hacks

  • Phil

    Hi Kyle,

    “You can also style the children accordingly this way if you’d like!”

    –> I love you for that, that was all I needed!!

  • Pingback: Wang Wang » Blog Archive » WordPress Help!

  • http://thesharath.com/ sharath

    i agree with garry. putting a display:none; attribute in the css could cause seriously penalization in the world of SEO & search engines….

    if you are using wp_list_categories then just use (‘exclude=1,50,6,54,44,7′) basically the numbers are the categories and sub categories that i dont want on the page :) simple but effective !!

  • http://html-mania.de Niklas

    The usual order to address this issue should be PHP > JavaScript > CSS
    The exclude trick works but you always have to go back to the template when adding a new subcategory which is fine as long as the system is maintained by a Developer. If you want to remove it dynamicly i suggest using jQuery.

    $(document).ready(function() {
    $(‘ul.children’).remove();
    });

    This script simply removes all unordered list’s with the class children.
    Your idea can be used as a backup solution if the clients JavaScript is disabled.