Blocking & Excluding Categories in Wordpress

  • : Function ereg() is deprecated in /chroot/home/spanishs/spanishseo.org/html/includes/file.inc on line 895.
  • : Function ereg() is deprecated in /chroot/home/spanishs/spanishseo.org/html/includes/file.inc on line 895.
  • : Function ereg() is deprecated in /chroot/home/spanishs/spanishseo.org/html/includes/file.inc on line 895.
  • : Function ereg() is deprecated in /chroot/home/spanishs/spanishseo.org/html/includes/file.inc on line 895.
  • : Function ereg() is deprecated in /chroot/home/spanishs/spanishseo.org/html/includes/file.inc on line 895.
  • : Function ereg() is deprecated in /chroot/home/spanishs/spanishseo.org/html/includes/file.inc on line 895.
  • : Function ereg() is deprecated in /chroot/home/spanishs/spanishseo.org/html/includes/file.inc on line 895.
  • strict warning: Non-static method view::load() should not be called statically in /chroot/home/spanishs/spanishseo.org/html/sites/all/modules/views/views.module on line 843.
  • strict warning: Declaration of views_plugin_display::options_validate() should be compatible with views_plugin::options_validate(&$form, &$form_state) in /chroot/home/spanishs/spanishseo.org/html/sites/all/modules/views/plugins/views_plugin_display.inc on line 1707.
  • strict warning: Declaration of views_plugin_display_block::options_submit() should be compatible with views_plugin_display::options_submit(&$form, &$form_state) in /chroot/home/spanishs/spanishseo.org/html/sites/all/modules/views/plugins/views_plugin_display_block.inc on line 184.
  • strict warning: Declaration of views_handler_field_broken::ui_name() should be compatible with views_handler::ui_name($short = false) in /chroot/home/spanishs/spanishseo.org/html/sites/all/modules/views/handlers/views_handler_field.inc on line 615.
  • strict warning: Declaration of views_handler_sort_broken::ui_name() should be compatible with views_handler::ui_name($short = false) in /chroot/home/spanishs/spanishseo.org/html/sites/all/modules/views/handlers/views_handler_sort.inc on line 82.
  • strict warning: Declaration of views_handler_filter::options_validate() should be compatible with views_handler::options_validate($form, &$form_state) in /chroot/home/spanishs/spanishseo.org/html/sites/all/modules/views/handlers/views_handler_filter.inc on line 585.
  • strict warning: Declaration of views_handler_filter::options_submit() should be compatible with views_handler::options_submit($form, &$form_state) in /chroot/home/spanishs/spanishseo.org/html/sites/all/modules/views/handlers/views_handler_filter.inc on line 585.
  • strict warning: Declaration of views_handler_filter_broken::ui_name() should be compatible with views_handler::ui_name($short = false) in /chroot/home/spanishs/spanishseo.org/html/sites/all/modules/views/handlers/views_handler_filter.inc on line 609.
  • strict warning: Declaration of views_plugin_row::options_validate() should be compatible with views_plugin::options_validate(&$form, &$form_state) in /chroot/home/spanishs/spanishseo.org/html/sites/all/modules/views/plugins/views_plugin_row.inc on line 124.
  • strict warning: Declaration of views_plugin_row::options_submit() should be compatible with views_plugin::options_submit(&$form, &$form_state) in /chroot/home/spanishs/spanishseo.org/html/sites/all/modules/views/plugins/views_plugin_row.inc on line 124.
  • strict warning: Non-static method view::load() should not be called statically in /chroot/home/spanishs/spanishseo.org/html/sites/all/modules/views/views.module on line 843.
  • strict warning: Declaration of views_handler_filter_many_to_one::init() should be compatible with views_handler_filter::init(&$view, $options) in /chroot/home/spanishs/spanishseo.org/html/sites/all/modules/views/handlers/views_handler_filter_many_to_one.inc on line 61.
  • strict warning: Declaration of views_handler_filter_term_node_tid::value_validate() should be compatible with views_handler_filter::value_validate($form, &$form_state) in /chroot/home/spanishs/spanishseo.org/html/sites/all/modules/views/modules/taxonomy/views_handler_filter_term_node_tid.inc on line 303.
  • warning: Creating default object from empty value in /chroot/home/spanishs/spanishseo.org/html/sites/all/modules/views/includes/handlers.inc on line 650.
  • strict warning: Non-static method view::load() should not be called statically in /chroot/home/spanishs/spanishseo.org/html/sites/all/modules/views/views.module on line 843.
  • : preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /chroot/home/spanishs/spanishseo.org/html/includes/unicode.inc on line 345.
  • : preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /chroot/home/spanishs/spanishseo.org/html/includes/unicode.inc on line 345.
  • : preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /chroot/home/spanishs/spanishseo.org/html/includes/unicode.inc on line 345.
 

WordpressSometimes we need to create a special category to feature posts or other information in the homepage or somewhere else, but don’t want it to appear in the template under the category list or get indexed by Search Engines because of potential duplicate content issues.

One alternative is to block that category from being indexed. The other option is to completely remove it from the template to limit any possibilities to be found and indexed. I will explore both techniques in this post.

Be aware that I will be using the ‘featured’ category with ID number 52 for example purposes.

Blocking Categories with Robots.txt

The easiest way to block the featured category from being indexed is by blocking the Search Engines using the disallow command in robots.txt:

User-agent: Googlebot
Disallow: /category/featured/


User-agent: *
Disallow: /category/featured/

Even though the category will be blocked, it will still appear in SERP if there are links pointing to it anywhere on the web. Make sure there are no external links to this category, or if there are, they should use the nofollow attribute value of the rel attribute in the <a> tag.

Nofollow and Noindex in the Robots Meta Tag

The best way to avoid indexing a page in the search results is by adding the noindex attribute in the Robots Meta tag in the header section of a page. Use this code in header.php between <head> and </head>:

<meta name="robots" content="noindex,follow" />

Keep in mind that even with the noindex attribute in the Robots Meta tag, links will be followed and PageRank (PR) will be distributed to other pages. If you don't want links to be followed, then replace the 'follow' attribute by 'nofollow'. The nofollow attribute will prevent the page from passing PR juice.

In addition to the changes in the Robots Meta tag, make sure that all internal links pointing to the featured category have the nofollow attribute.

The nofollow attribute in the Robots Meta tag applies to the entire page, and the nofollow attribute on the link (<a> tag) applies only to that link.

The Navigation Menu

If the featured category shows up in the navigation menu, you will have to remove it by adding &exclude=cat_ID to <?php wp_list_categories(); ?>. The navigation menu is normally located in header.php.

cat_ID is the number assigned to the featured category. This can be found by hovering the mouse over the category name under the manage categories section. Information about the category will appear at the left bottom corner and will look similar to this:

http://www.yoursite.com/wp-admin/post.php?action=edit&post=52

Category List in the Sidebar

If you are using a widget to show categories in the sidebar, then you will have to make changes to the widget according to the developer’s suggestions.

But if the category list was hard coded in the template, most likely you will have to edit sidebar.php to exclude the featured category by adding &exclude=cat_ID to <?php wp_list_categories(); ?>.

This an example of the code that shows all categories in the sidebar in a nested list, sorts them by name, and excludes category 52:

<?php wp_list_categories('sort_column=name&title_li=&exclude=52'); ?>

The process is very similar for the sitemap.

Blog's Sitemap

If you have a sitemap in your blog, it is very likely that is named sitemap.php. You will have to remove the featured category from the category list by adding &exclude=cat_ID to<?php wp_list_categories(); ?>.

This is an example of the code that lists all categories in the sitemap, sorts them by name and excludes category 52:

<?php wp_list_cats('sort_column=name&exclude=52'); ?>

Blog's Main Page

This could be either your homepage or a page located in a folder such as /blog. As you can see in our Multilingual SEO blog page, each post shows the category to which was assigned, right next to 'Filed under' at the end of the post.

If you don’t make any changes to the code in this section, the featured category will appear next to other categories to which were also assigned.

To remove the featured category simply replace <?php the_category(', ') ?> with this code:
<?php foreach((get_the_category()) as $cat) { if (!($cat->cat_ID=='52')) echo '<a href="' . get_bloginfo('url') . '/category/' . $cat->category_nicename . '/">'. $cat->cat_name . '</a>' . ', '; } ?>

Make sure to change cat_ID=='52' for the number of the category you are removing.

Category Pages

Posts assigned to one or more categories are contained in one or several pages. At the end of the post, the categories to which they were assigned appear next to 'Filed under'. To remove the featured category replace <?php the_category(', ') ?> in archive.php with the following code:
<?php foreach((get_the_category()) as $cat) { if (!($cat->cat_ID=='52')) echo '<a href="' . get_bloginfo('url') . '/category/' . $cat->category_nicename . '/">'. $cat->cat_name . '</a>' . ', '; } ?>

Make sure to change cat_ID=='52' for the number of the category you are removing.

In case you deal with pagination make an effort to use the nofollow attribute for links to the second, third, or fourth pages as well as noindex attribute in the Robots Meta tag in those same pages. Enjoy it :)

No votes yet
3 comments

Ali Hussain

Ali Hussain's picture

Thank you!

Your subject is a good one, but for a blog to be worthwhile you need to post at least weekly. Your site is just loaded with information so this shouldn’t be an issue. If you need an SEO writer you can always find one online for a very low cost, or you could hire someone that really knows the subject and pay a decent price per article.

Skilled writer will cost 25Euros or more per site. A novice will write 10 articles for the same 25. Think about it, it can really be worth the cost.

Augusto Ellacuriaga

Augusto Ellacuriaga's picture

Hi Richard,

I don’t agree 100% with your concept about having to post at least once a week for a blog to be worthwhile. In fact, if a blogger gets into that mindframe, he/she is forced to produce content that sometimes is plain garbage. Just look around the web to see some examples.

On the other hand, there are great blogs that write interesting pieces on an ongoing basis. It’s more of a personal choice that depends on the overall Internet Marketing strategy than, say, a norm. From the SEO, ORM, SMM, etc. there is no doubt that it will be helpful to update content constantly.

The main reason for not updating this blog is because I have been pretty busy with client’s projects, personal ones and interacting in private communities. I know, that shouldn’t be an excuse, but that was the decision.

As we speak, this Sunday I am reviewing some advance Adobe Illustrator techniques to finish the logos for the more than 15 personal projects in queue.

In regards to copywriting, the price someone pays for an article is in direct proportion to its quality. I don’t support low paying strategies as a mean of fulfilling a blog. I’d rather write when I have the time, passion and there is something good I can contribute. Otherwise, I’ll keep my perspectives, call it stupidity if you want, for a few close ones instead of broadcasting them to the world.

I even created a new template in Drupal for this site that haven’t been deployed yet. Will do that in the upcoming days.

Thanks for igniting the fire on me:)