I recently moved a parent category and its children from the default categories taxonomy to a new custom taxonomy. The data moved over just fine and posts are properly associated with the company name in the the new company taxonomy.


  • Taxonomy: Category
  • Term: Company
  • Child Term: Mozilla


  • Taxonomy: Company
  • Term: Mozilla

The problem I just ran into is that when I display the terms associated with the post using the_terms is builds the url as follows:


I knew I could fake the correct results by manually building the URL, but I wanted to understand why it was happening. What I was hoping to figure out was why the double slash was happening and how to fix it.

2 Answers 2


First Assumption: That an extra slash was being added for some reason

To see what was going on, I wanted to see what was going on in the array. When I print_r() the array I get the following:

 Array ( 
      [10] => stdClass Object ( 
           [term_id] => 10 
           [name] => Mozilla 
           [slug] => mozilla 
           [term_group] => 0 
           [term_taxonomy_id] => 11 
           [taxonomy] => company 
           [description] => 
           [parent] => 504 
           [count] => 8 
           [object_id] => 37085 
           [filter] => raw 

Everything looked pretty normal until I noticed the [parent] => 504 value, which I knew was moved over when the terms were moved from Category taxonomy to the Company taxonomy (I thought it wouldn't matter at the time).

This new knowledge helped me to come to a new assumption.

Second & Correct Assumption: That there was something missing between the two slashes.

Instead of seeing the second slash as being extra, my new idea was that the non-existent parent was missing from url:

  • Before: example.com/category/company/mozilla
  • After: example.com/company/(missing parent)/mozilla

To test if this was the problem, I changed the database value [parent] => 504 to [parent] => 0 to remove any parent association and it worked as expected to create the correct url:



Just if anynone else will be searching for the same. To fix the issue check your register_taxonomy() rewrite syntax. There should be no trailing slash. Note the '/product-category' without ending slash in the code sample below:

    array('product', 'post'), array(
        'label' => __('Product Categories'),
        'rewrite' => array('slug' => '/product-category'),
        'hierarchical' => true,
        'show_admin_column' => true,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.