Tagged: 

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1106

    The categories I use in my slider are the same categories I want hidden in menus… when I tell the system to hide these they still show up. the categories are featured, featured2, featured3, featured4 and featured5. Here is my site http://www.101river.com

    #34018

    Hey,

    If you want to “hide” categories, delete them. However you try to “hide” them, a search engine will index the complete site (except where you specify exclusions in robots.txt) and will pick them up.

    I’d recommend using a generic category such as “featured” or “slides” for the slider entries.

    James

    #34019

    I just don’t want them to show up on the home page or anywhere else… as you can see on my home page the categories “featured 1-5″ are showing in the menu half way down the page.

    http://www.101river.com

    how do I hide these? In the content manager it says “hide” the categories that you do not want to show.

    #34020

    Hey,

    For widgets:

    This plugin will allow you to exclude the categories of your choice from a categories widget.

    For posts, archives and other pages:

    1.) Add this to the end of functions.php:

    function JMD_exclude_category($excludedcats = array()){
    $count = 0;
    $categories = get_the_category();
    foreach($categories as $category) {
    $count++;
    if ( !in_array($category->cat_ID, $excludedcats) ) {
    echo '<a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "Posted in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a>';

    if( $count != count($categories)-1 ) echo ", "; // so the last category to display won't show a comma

    }
    }
    }

    2.) Open up single.php and archive.php; replace this code:

    <span class="categories"><?php the_category(', '); ?></span>

    with this code:

    <span class="categories"><?php JMD_exclude_category(array(1,2,3,4)); ?></span>

    then replace 1,2,3,4 with the ID’s of the categories you want to exclude (comma separated).

    Note: This will not stop you being able to access excluded categories directly on their archive page. You should also consider blocking access to these files for spiders using robots.txt and use a plugin such as Redirection to stop direct access to the archive pages.

    Let me know how you get on. :)

    James

    #34021

    Ok I did as you said and I am getting the same results. http://www.101river.com

    #34022

    Hey cleanclearco,

    Have you tried making a menu with just the categories you want listed and then using the custom menu widget? I think it might work for you.

    Good luck.

    #34023

    Hey,

    What category ID’s did you enter to this function?

    <?php JMD_exclude_category(array(1,2,3,4)); ?>

    James

    #34024

    <span class=”categories”><?php JMD_exclude_category(array(45,40,49,47)); ?></span>

    #34025

    Hey,

    I’ve had a look through your site, you’ve excluded Featured / Featured 2 / Featured 3 and Featured 5 (not Featured 4).

    If you look at Featured 4 you can see that the category name appears (http://cl.ly/99897679037dc369dd84) whereas if you look at Featured 5 you can see that the category is hidden (http://cl.ly/4b3c244ec0b361e809e7) so the function works just fine.

    As I said before:

    Note: This will not stop you being able to access excluded categories directly on their archive page. You should also consider blocking access to these files for spiders using robots.txt and use a plugin such as Redirection to stop direct access to the archive pages.

    James

Viewing 9 posts - 1 through 9 (of 9 total)

The topic ‘Categories will not hide’ is closed to new replies.