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
Categories will not hide
9 posts from 3 voices-
Posted 2 years ago #
-
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
Posted 2 years ago # -
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.
how do I hide these? In the content manager it says "hide" the categories that you do not want to show.
Posted 2 years ago # -
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
Posted 2 years ago # -
Ok I did as you said and I am getting the same results. http://www.101river.com
Posted 2 years ago # -
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.
Posted 2 years ago # -
Hey,
What category ID's did you enter to this function?
<?php JMD_exclude_category(array(1,2,3,4)); ?>James
Posted 2 years ago # -
<span class="categories"><?php JMD_exclude_category(array(45,40,49,47)); ?></span>
Posted 2 years ago # -
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
Posted 2 years ago #
Reply
You must log in to post.














