How to fix a double slash in custom permalinks with hierarchical taxonomy’s?

There is a quick and somewhat dirty potential solution to this. I say ‘potential’ because I can’t spot the problem by looking at the code. I only have my suspicions. Instead of passing a separator like that. Try trailingslashit.

} else    
    $chain .= trailingslashit($name);
return $chain;  

I am guessing at where the problem is based on your description, but that is the only place that $separator is applied.

There is a case where this simple fix won’t work. If $name is empty, you will get an extra slash in your string, so it would be better to check for that, just in case.

} elseif (!empty($name))     
    $chain .= trailingslashit($name);
return $chain;

Try that.

Leave a Comment