Change how the categories are listed for posts

Most themes have a link to each category in underneath the title of the post on the individual posts.

These links are rarely if ever, styled, and in most cases push “link-juice” toward the category page.

This is not good for SEO, so the best solution is to change the way the categories for the post is displayed.


You will have to edit your theme for this, so this is not for beginners.


1. Find and locate your “single.php” file in your theme.

2. Find the following code

<?php the_category(', ') ?>

Now, there are several ways to change it. The first solution is to simply list the categories without having any links to them. That can be done by replacing above code with the following:

foreach((get_the_category()) as $category) {
echo $category->cat_name . ' ';

This just lists all categories as a long line.

The second solution is to list the categories as you usually would, but by adding rel=”nofollow” to the links, so you do not pass link-juice to the category pages.

This can be done with the following code:

foreach((get_the_category()) as $category) {
if ($catcount>1) {echo ', '; }
echo '<a href='.get_category_link($category->cat_ID).' rel='nofollow category tag'>' . $category->cat_name. '</a>';

The $catcount variable is a little code I added which displays a comma if there are more than one category. If we did not check for this, the code would simply add a comma every time, even if there was just one category listed.

If you want to use something else such as “and”  instead of the ,”” comma, change the following line:

if ($catcount<1) {echo ', '; }


if ($catcount>1) {echo 'and '; }

If you are looking for other tips and tricks, check out Setting Featured Image via code or WordPress Multisite Search.

Cleverplugins newsletter

Never miss a story or discount - sign up now

Cleverplugins Newsletter

Never miss a story or discounts - sign up now