Double slash in the_terms URL

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 
           Double slash in the_terms URL => 
           [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:

http://example.com/company/mozilla

error code: 523