PressTigers

How to Change Permalink Structure for Custom Post Type/Taxonomy

Permalinks on a site are crucial, specially for Search Engine Optimization. Let’s say you have a custom post type named as directory and its default URL structure is www.mysite.com/directory/directory-name. But you want to change it by adding the category base of custom post type. So, after the change it should be something like www.mysite.com/directory/my-category/directory-name.

In order to change the permalink structure, first and foremost thing is to change the value of ‘rewrite’ parameter where your custom post type is being registered. It should be like:

Here ‘directory-category’ is the slug of category/taxonomy of the custom post type named ‘directory’.

After implementing the change described above, you need to add the following code in your Theme’s/Child Theme’s functions.php file:

This code will lead to the change required in permalink structure of your custom post type including the category/taxonomy in it.

User Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

    Get in Touch