Make Taxonomy Slug SEO Friendly

Taxonomy Slug SEO Friendly

Hello Friends, Today we will talk about how to make our website taxonomy slugs SEO friendly. First, we will give you a tip for SEO Friendly URL, this is an important part to make website SEO friendly. Sometimes developers use underscores to separate words in the URL of Pages/Posts instead of using dashes. Underscore is a bad thing in URL for SEO perspective, if you want to make website SEO friendly then we have to use dashes instead of underscores.

Wait, let me show you an example, the URL in the screenshot is not an SEO friendly URL:

underscore in slug

Above is an example of single Portfolio page, where you will see that there is an underscore which is separating portfolio & items in the URL. Many paid WordPress themes don’t have the feature to make custom slug for these type of taxonomies like Portfolio, Courses etc…

So today, we will learn how to make taxonomy slug SEO friendly. Friends, you have to follow below steps:

STEP 1: Copy the below code and paste in function.php file which located in your activated child-theme.

function py_modify_taxonomy() {
    // get the arguments of the already-registered taxonomy
    $people_category_args = get_taxonomy( 'projects_category' );
    $people_category_args->show_admin_column = true;
    $people_category_args->rewrite['slug'] = 'projects';
    $people_category_args->rewrite['with_front'] = false;

    // re-register the taxonomy
    register_taxonomy( 'projects_category', 'projects', (array) $people_category_args );
}
// hook it up to 11 so that it overrides the original register_taxonomy function
add_action( 'init', 'py_modify_taxonomy', 11 );

STEP 2: Replace the ‘project_category’ in above code to either ‘projects’ or ‘project-category’ and then update function.php file

STEP 3: After updating function.php file, Go to Setting >> Permalinks

setting-permalinks

STEP 4: On Permalinks page, scroll to the bottom and hit the Publish button. You will see that underscore have been replaced with either a text or a dashed as per your need. Thanks

Slug changed

Share:

Facebook
Twitter
Pinterest
LinkedIn

Please share your thought