How to Convert WordPress Categories to Custom Taxonomies

Do you want to convert your WordPress categories into custom taxonomies? Categories are one of the two default taxonomies that help you sort your content. However, WordPress also allows you to create and use custom taxonomies. In this article, we will show you how to… Read More »

The post How to Convert WordPress Categories to Custom Taxonomies appeared first on WPBeginner.

Do you want to convert your WordPress categories into custom taxonomies? Categories are one of the two default taxonomies that help you sort your content. However, WordPress also allows you to create and use custom taxonomies. In this article, we will show you how to easily convert WordPress categories into custom taxonomies.

How to Convert WordPress Categories to Custom Taxonomies

Why and When Do You Need to Convert Categories to Custom Taxonomies

Categories and tags are the two default taxonomies in WordPress. Taxonomies are used to sort and organize content into different topics.

Apart from the default taxonomies, WordPress also allows you to create custom taxonomies which you can use with existing post types or with custom post types. For more on this topic, see our article on when do you need a custom post type or taxonomy in WordPress.

As your website grow, you might find a need to convert your categories into a custom taxonomy. For example, let’s say that you have a category called topics with a lot of sub-categories. It would be time-consuming to edit each post and file it under your new custom taxonomy.

Wouldn’t it be nice if you could bulk convert some or all of your categories to the new custom taxonomy?

Let’s take a look at how you can easily convert categories to custom taxonomies without manually editing each post.

Converting WordPress Categories to Custom Taxonomies

First thing you need to do is install and activate Taxonomy Switcher plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Upon activation, you need to visit Tools » Taxonomy Switcher page in your WordPress admin area to convert categories to custom taxonomies.

Taxonomy Switcher

On this page, you can select the taxonomies you want to convert. For this tutorial, we will select ‘Categories’ as the taxonomy we want to switch from, and ‘Topics’ as the custom taxonomy we want to switch to.

Select taxonomies

If you want to convert all categories to a custom taxonomy, then you can go ahead and click on the ‘Switch Taxonomies’ button.

The plugin will convert all categories to your selected custom taxonomy. You will see a success message like this:

Successfully switched taxonomies

If you just want to convert specific categories, then you will need to add the IDs of those categories next to ‘Comma separated list of term ids to switch’ field. See our article on how to find category IDs in WordPress for more details.

Skip categories

Additionally, if you want to skip child categories of a specific category, then you can add the IDs of the parent category next to ‘Limit taxonomy switch for child terms of a specific parent’ option.

Don’t forget to click on the ‘Switch Taxonomy’ button to save your changes.

Setting Up Redirects from Category to Custom Taxonomy

After you switch categories to a custom taxonomy, the category archive page will now show a 404 error page. This is nothing to be worried about if your website is not live yet.

However if your website is live, then search engines may have already crawled your category pages and indexed them. This means that those pages can appear in search results and users coming from search engines will see a 404 error page.

To fix this, you need to redirect users to the new taxonomy page for each category.

Luckily, there is an easy fix for that.

First, you will need to install and activate the Redirection plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Upon activation, you need to visit Tools » Redirection page. In the Source URL field, you need to enter /category/.* and in the Target URL field you need to enter your custom taxonomy slug, e.g. /topic/$1

Set up redirects

Next, you need check the box next to ‘Regex’ option, and then click on ‘Add Redirect’ button.

This redirect will now send all category archive traffic to your custom taxonomy. Only use this, if you don’t want to use categories at all.

If you want to redirect individual categories to a custom taxonomy page, then see our beginner’s guide on setting up redirects in WordPress with detailed step by step instructions.

We hope this article helped you learn how to convert WordPress categories to custom taxonomies. You may also want to see our guide on how to style individual categories differently in WordPress to style your custom taxonomy templates.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post How to Convert WordPress Categories to Custom Taxonomies appeared first on WPBeginner.

How to Convert WordPress Categories to Custom Taxonomies

Do you want to convert your WordPress categories into custom taxonomies? Categories are one of the two default taxonomies that help you sort your content. However, WordPress also allows you to create and use custom taxonomies. In this article, we will show you how to… Read More »

The post How to Convert WordPress Categories to Custom Taxonomies appeared first on WPBeginner.

Do you want to convert your WordPress categories into custom taxonomies? Categories are one of the two default taxonomies that help you sort your content. However, WordPress also allows you to create and use custom taxonomies. In this article, we will show you how to easily convert WordPress categories into custom taxonomies.

How to Convert WordPress Categories to Custom Taxonomies

Why and When Do You Need to Convert Categories to Custom Taxonomies

Categories and tags are the two default taxonomies in WordPress. Taxonomies are used to sort and organize content into different topics.

Apart from the default taxonomies, WordPress also allows you to create custom taxonomies which you can use with existing post types or with custom post types. For more on this topic, see our article on when do you need a custom post type or taxonomy in WordPress.

As your website grow, you might find a need to convert your categories into a custom taxonomy. For example, let’s say that you have a category called topics with a lot of sub-categories. It would be time-consuming to edit each post and file it under your new custom taxonomy.

Wouldn’t it be nice if you could bulk convert some or all of your categories to the new custom taxonomy?

Let’s take a look at how you can easily convert categories to custom taxonomies without manually editing each post.

Converting WordPress Categories to Custom Taxonomies

First thing you need to do is install and activate Taxonomy Switcher plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Upon activation, you need to visit Tools » Taxonomy Switcher page in your WordPress admin area to convert categories to custom taxonomies.

Taxonomy Switcher

On this page, you can select the taxonomies you want to convert. For this tutorial, we will select ‘Categories’ as the taxonomy we want to switch from, and ‘Topics’ as the custom taxonomy we want to switch to.

Select taxonomies

If you want to convert all categories to a custom taxonomy, then you can go ahead and click on the ‘Switch Taxonomies’ button.

The plugin will convert all categories to your selected custom taxonomy. You will see a success message like this:

Successfully switched taxonomies

If you just want to convert specific categories, then you will need to add the IDs of those categories next to ‘Comma separated list of term ids to switch’ field. See our article on how to find category IDs in WordPress for more details.

Skip categories

Additionally, if you want to skip child categories of a specific category, then you can add the IDs of the parent category next to ‘Limit taxonomy switch for child terms of a specific parent’ option.

Don’t forget to click on the ‘Switch Taxonomy’ button to save your changes.

Setting Up Redirects from Category to Custom Taxonomy

After you switch categories to a custom taxonomy, the category archive page will now show a 404 error page. This is nothing to be worried about if your website is not live yet.

However if your website is live, then search engines may have already crawled your category pages and indexed them. This means that those pages can appear in search results and users coming from search engines will see a 404 error page.

To fix this, you need to redirect users to the new taxonomy page for each category.

Luckily, there is an easy fix for that.

First, you will need to install and activate the Redirection plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Upon activation, you need to visit Tools » Redirection page. In the Source URL field, you need to enter /category/.* and in the Target URL field you need to enter your custom taxonomy slug, e.g. /topic/$1

Set up redirects

Next, you need check the box next to ‘Regex’ option, and then click on ‘Add Redirect’ button.

This redirect will now send all category archive traffic to your custom taxonomy. Only use this, if you don’t want to use categories at all.

If you want to redirect individual categories to a custom taxonomy page, then see our beginner’s guide on setting up redirects in WordPress with detailed step by step instructions.

We hope this article helped you learn how to convert WordPress categories to custom taxonomies. You may also want to see our guide on how to style individual categories differently in WordPress to style your custom taxonomy templates.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post How to Convert WordPress Categories to Custom Taxonomies appeared first on WPBeginner.

How to Style Individual Categories Differently in WordPress

Do you want to style categories differently in WordPress? Most WordPress themes use the same style for all category archive pages. However, if you run a content rich website, then you can style each category differently to maximize their potential. In this article, we will… Read More »

The post How to Style Individual Categories Differently in WordPress appeared first on WPBeginner.

Do you want to style categories differently in WordPress? Most WordPress themes use the same style for all category archive pages. However, if you run a content rich website, then you can style each category differently to maximize their potential. In this article, we will show you how to easily style categories differently in WordPress.

How to style categories differently in WordPress

Why Style Categories Differently in WordPress?

As we said earlier, most WordPress themes use the same template for each category archive page. That’s because theme developers don’t know how you will be using the categories on your website and what those categories will be.

However, if you are running a content rich site, then changing the layout of a category archive page can have a dramatic impact on how users engage with the content on that page.

For example, if you run a news or magazine site, then you can have local ads displayed on the local news category. You can show weather information, show most popular stories in that category, and so on.

Having said that, let’s see how to easily style individual categories differently in WordPress.

Styling Individual Categories Differently in WordPress

There are multiple ways to style categories in WordPress. We will show you two different methods to style categories, and you can choose the one that best suits your needs and skill level.

Using Single Category Template in WordPress Theme

WordPress themes follow a standard template hierarchy. Depending on a template file name, WordPress can automatically pick the right template to display a page.

For example, it looks for category.php file to display category archive pages.

WordPress also allows you to create templates for individual categories as well. Let’s suppose you want to style the ‘Apple’ category differently. You can do that by adding a new template file to your theme and naming it category-apple.php.

Connect to your WordPress site using an FTP client and then go to /wp-content/themes/your-current-theme/ folder and create a new file category-apple.php. Don’t forget to replace apple with your own category name.

Creating a template for individual category in your WordPress theme

You can use your theme’s category.php file as a starting point. Simply edit and copy all of its content. Now edit your newly created category-apple.php file and paste the code inside it.

After that you can start making changes to your individual category template. You can create and use a different sidebar for this category, make it a full-width page, add a welcome message, or anything else you want.

Style Individual Categories in WordPress Using CSS

WordPress automatically adds CSS classes to different elements throughout your website. These include both the body class and the post class.

For example, if you view a category archive page and then use the Inspect Tool, you will notice category and category-name CSS classes in the body tag.

Category class added to body element by WordPress

You can use this CSS class to style each individual category differently by adding custom CSS.

Here is some example CSS that you can use as a starting point.

body.category-apple { 
background-color:#EEE;
background:url("http://example.com/wp-content/uploads/2017/background.jpg") no-repeat fixed;
color:#FFFFFF;
}
.category-apple .site { 
background:#232323; 
}
.category-apple a { 
color:#CCCCCC; 
} 

Don’t forget to change the category name in the CSS class with your own category name.

Changing category style using CSS

We hope this article helped you learn how to style categories differently in WordPress. You may also want to see our list of most wanted category hacks and plugins for WordPress.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post How to Style Individual Categories Differently in WordPress appeared first on WPBeginner.

How to Style Individual Categories Differently in WordPress

Do you want to style categories differently in WordPress? Most WordPress themes use the same style for all category archive pages. However, if you run a content rich website, then you can style each category differently to maximize their potential. In this article, we will… Read More »

The post How to Style Individual Categories Differently in WordPress appeared first on WPBeginner.

Do you want to style categories differently in WordPress? Most WordPress themes use the same style for all category archive pages. However, if you run a content rich website, then you can style each category differently to maximize their potential. In this article, we will show you how to easily style categories differently in WordPress.

How to style categories differently in WordPress

Why Style Categories Differently in WordPress?

As we said earlier, most WordPress themes use the same template for each category archive page. That’s because theme developers don’t know how you will be using the categories on your website and what those categories will be.

However, if you are running a content rich site, then changing the layout of a category archive page can have a dramatic impact on how users engage with the content on that page.

For example, if you run a news or magazine site, then you can have local ads displayed on the local news category. You can show weather information, show most popular stories in that category, and so on.

Having said that, let’s see how to easily style individual categories differently in WordPress.

Styling Individual Categories Differently in WordPress

There are multiple ways to style categories in WordPress. We will show you two different methods to style categories, and you can choose the one that best suits your needs and skill level.

Using Single Category Template in WordPress Theme

WordPress themes follow a standard template hierarchy. Depending on a template file name, WordPress can automatically pick the right template to display a page.

For example, it looks for category.php file to display category archive pages.

WordPress also allows you to create templates for individual categories as well. Let’s suppose you want to style the ‘Apple’ category differently. You can do that by adding a new template file to your theme and naming it category-apple.php.

Connect to your WordPress site using an FTP client and then go to /wp-content/themes/your-current-theme/ folder and create a new file category-apple.php. Don’t forget to replace apple with your own category name.

Creating a template for individual category in your WordPress theme

You can use your theme’s category.php file as a starting point. Simply edit and copy all of its content. Now edit your newly created category-apple.php file and paste the code inside it.

After that you can start making changes to your individual category template. You can create and use a different sidebar for this category, make it a full-width page, add a welcome message, or anything else you want.

Style Individual Categories in WordPress Using CSS

WordPress automatically adds CSS classes to different elements throughout your website. These include both the body class and the post class.

For example, if you view a category archive page and then use the Inspect Tool, you will notice category and category-name CSS classes in the body tag.

Category class added to body element by WordPress

You can use this CSS class to style each individual category differently by adding custom CSS.

Here is some example CSS that you can use as a starting point.

body.category-apple { 
background-color:#EEE;
background:url("http://example.com/wp-content/uploads/2017/background.jpg") no-repeat fixed;
color:#FFFFFF;
}
.category-apple .site { 
background:#232323; 
}
.category-apple a { 
color:#CCCCCC; 
} 

Don’t forget to change the category name in the CSS class with your own category name.

Changing category style using CSS

We hope this article helped you learn how to style categories differently in WordPress. You may also want to see our list of most wanted category hacks and plugins for WordPress.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post How to Style Individual Categories Differently in WordPress appeared first on WPBeginner.

How to Style Individual Categories Differently in WordPress

Do you want to style categories differently in WordPress? Most WordPress themes use the same style for all category archive pages. However, if you run a content rich website, then you can style each category differently to maximize their potential. In this article, we will… Read More »

The post How to Style Individual Categories Differently in WordPress appeared first on WPBeginner.

Do you want to style categories differently in WordPress? Most WordPress themes use the same style for all category archive pages. However, if you run a content rich website, then you can style each category differently to maximize their potential. In this article, we will show you how to easily style categories differently in WordPress.

How to style categories differently in WordPress

Why Style Categories Differently in WordPress?

As we said earlier, most WordPress themes use the same template for each category archive page. That’s because theme developers don’t know how you will be using the categories on your website and what those categories will be.

However, if you are running a content rich site, then changing the layout of a category archive page can have a dramatic impact on how users engage with the content on that page.

For example, if you run a news or magazine site, then you can have local ads displayed on the local news category. You can show weather information, show most popular stories in that category, and so on.

Having said that, let’s see how to easily style individual categories differently in WordPress.

Styling Individual Categories Differently in WordPress

There are multiple ways to style categories in WordPress. We will show you two different methods to style categories, and you can choose the one that best suits your needs and skill level.

Using Single Category Template in WordPress Theme

WordPress themes follow a standard template hierarchy. Depending on a template file name, WordPress can automatically pick the right template to display a page.

For example, it looks for category.php file to display category archive pages.

WordPress also allows you to create templates for individual categories as well. Let’s suppose you want to style the ‘Apple’ category differently. You can do that by adding a new template file to your theme and naming it category-apple.php.

Connect to your WordPress site using an FTP client and then go to /wp-content/themes/your-current-theme/ folder and create a new file category-apple.php. Don’t forget to replace apple with your own category name.

Creating a template for individual category in your WordPress theme

You can use your theme’s category.php file as a starting point. Simply edit and copy all of its content. Now edit your newly created category-apple.php file and paste the code inside it.

After that you can start making changes to your individual category template. You can create and use a different sidebar for this category, make it a full-width page, add a welcome message, or anything else you want.

Style Individual Categories in WordPress Using CSS

WordPress automatically adds CSS classes to different elements throughout your website. These include both the body class and the post class.

For example, if you view a category archive page and then use the Inspect Tool, you will notice category and category-name CSS classes in the body tag.

Category class added to body element by WordPress

You can use this CSS class to style each individual category differently by adding custom CSS.

Here is some example CSS that you can use as a starting point.

body.category-apple { 
background-color:#EEE;
background:url("http://example.com/wp-content/uploads/2017/background.jpg") no-repeat fixed;
color:#FFFFFF;
}
.category-apple .site { 
background:#232323; 
}
.category-apple a { 
color:#CCCCCC; 
} 

Don’t forget to change the category name in the CSS class with your own category name.

Changing category style using CSS

We hope this article helped you learn how to style categories differently in WordPress. You may also want to see our list of most wanted category hacks and plugins for WordPress.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post How to Style Individual Categories Differently in WordPress appeared first on WPBeginner.

How to Display Category Descriptions in WordPress

Do you want to display category descriptions on your WordPress site? Categories allow you to easily sort content on your website. They also help users easily find content and are good for SEO. In this article, we will show you how to easily display category… Read More »

The post How to Display Category Descriptions in WordPress appeared first on WPBeginner.

Do you want to display category descriptions on your WordPress site? Categories allow you to easily sort content on your website. They also help users easily find content and are good for SEO. In this article, we will show you how to easily display category descriptions in WordPress.

How to display category description in WordPress

Adding Category Descriptions in WordPress

WordPress comes with two built-in taxonomies called categories and tags. These taxonomies allow you to easily sort your content into different topics.

When used correctly, categories and tags can also be very helpful in improving your WordPress SEO.

WordPress allows you to add descriptions for your categories. However, many users don’t notice it because they create categories when writing a post which doesn’t let them add description.

Here is how to easily add description to your categories.

Head over to Posts » Categories page. If you are creating a new category, then you can simply enter category name and description here and then click on ‘Add new category’ button.

Add category description

If you want to add description to an existing category, then you need to click on the ‘Edit’ link below that category.

This will take you to category edit screen where you can add description for your category.

Editing a category to add description

Don’t forget to click on the ‘Update’ button to save your changes.

Repeat the process to add descriptions to all your categories. You can use the same method to add descriptions for tags as well.

Display Category Description on Category Archive Page

Most WordPress themes will automatically display the category description on the category archive pages.

Category description shown on category archive page in WordPress

However if your theme does not display category description on archive pages, then you will need to edit your theme files.

Connect to your WordPress site using an FTP client and then go to /wp-content/themes/your-current-theme/ folder.

Now you will need to locate and edit category.php file. If your theme doesn’t have category.php file, then you will need to edit archive.php file.

Copy and paste this code where you would like the category description to be displayed.

<?php 
the_archive_description( '<div class="taxonomy-description">', '</div>' ); 
?>

You can now save your changes and upload the file back to your website.

After that, you can visit the category archive page on your website to see the description in action.

Display Category Description in WordPress Theme

If you want to display the category description in other parts of your website, then you can also use the category_description template tag:

<?php echo category_description(3); ?>

Don’t forget to replace 3 with your own category ID.

If you want to display category description inside a single post, then you can use this code.

$catID = get_the_category();
echo category_description( $catID[0] ); 

This code simply gets all categories for the current post and then outputs the category description of the first category.

If you would like to list all your WordPress categories with a description in list format, then you can add this code in your theme’s functions.php file:

function wpb_catlist_desc() { 
$string = '<ul>';
$catlist = get_terms( 'category' );
if ( ! empty( $catlist ) ) {
  foreach ( $catlist as $key => $item ) {
    $string .= '<li>'. $item->name . '<br />';
    $string .= '<em>'. $item->description . '</em> </li>';
  }
}
$string .= '</ul>';

return $string; 
}
add_shortcode('wpb_categories', 'wpb_catlist_desc');

This code creates a shortcode which displays all your categories and their descriptions in a plain list.

You can now use [wpb_categories] in your posts and pages. To use this shortcode inside a text widget, you will need to enable shortcodes for widgets.

List WordPress categories with description

We hope this article helped you learn how to add and display category descriptions in WordPress. You may also want to see our list of most wanted category hacks and plugins for WordPress.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post How to Display Category Descriptions in WordPress appeared first on WPBeginner.