This should do the trick:
$sep = '»';
$parents = get_category_parents( $cat, TRUE, $sep );
$parents = explode( $sep, trim( $parents, $sep ) );
$parents = array_reverse( $parents );
$parents = implode( " $sep ", $parents );
print $parents;
Some categories lost letters in the end of the word when using Michael Fields trick. I changed the code a little bit and now it seems to work. I don’t know what this bug came from. It works when I use:
if(is_archive()){
$sep = " ‹ ";
$parents = get_category_parents( $cat, FALSE, $sep );
$parents = trim($parents);
$parents = explode($sep,$parents);
$parents = array_reverse($parents);
$parents = implode(" ",$parents );
print $parents . " ‹ ";
}
The problem seems to occur when I using the explode() and trim() at the same row…
@smeknamn great catch! Sorry for the oversight. Sometimes I forget what the second parameter passed to trim() actually does. Instead of removing the string trim() removes the individual characters as shown in the Hello World example in the docs: http://php.net/manual/en/function.trim.php