0

I'm using the theme TwentyThriteen1.0 for my WordPress blog.

I recognized that the tags in the meta-part of an article are not separated by a comma. I had a look at the function twentythirteen_entry_meta() in the file functions.php of my theme, which contains:

$tag_list = get_the_tag_list( '', __( ', ', 'twentythirteen' ) );

According to the documentation for get_the_tag_list() (http://codex.wordpress.org/Function_Reference/get_the_tag_list), the tags should be separated by a space after the comma. Looking at the HTML source reveals </a>,<a href=, instead of </a>, <a href=.

When I now add a space in the functions.php in front of the comma:

$tag_list = get_the_tag_list( '', __( ' , ', 'twentythirteen' ) );

the HTML source has both spaces: </a> , <a href=. This is really strange to me,... Is this a error or deliberate?

Or is this an error of the function translate() (alias __()) that removes trailing spaces if there are no leading spaces? I'm using the german version of Wordpress.

1 Answer 1

0

There is a possibility, that this string has been already translated and WP is displaying the translation, which has another format.

Try to pass a comma without a function, or take look at _x, where you can specify the context, you are translating.

EDIT

/**
 * Function fixes unknown issue of an unusual space in the tag list
 * @param string $html a piece of html code
 * @ return string
 */
function fix_tags_separator_bug($html){
    $separator = ", ";
    return preg_replace("/(\s){0,},(\s){0,1}/", $separator, $html);
}
add_filter("the_tags", "fix_tags_separator_bug");
2
  • Actually I'd like to avoid changing the standard TwentyThriteen design. (I'm only using a child design). I also don't want to copy paste stuff, if no necessary. It really looks like an error,... Don't you have the same problem? Why should in one case the space be removed, but not in the other?
    – Sven
    Commented Nov 11, 2013 at 19:09
  • Actually, never have I had such an issue :-D. (I checked my twentythirteen, it works properly) First thing I would take look at, while not wanting to change the core files, are files of translation, if you do have any. Have a look at my EDIT, I wrote simple function, replacing the comma with spaces, with your custom separator stated inside the function. Be aware that this function replaces this value globally on your site. So, in the weirdest case, you might in the functions file, put yourself a character, e.g. x|x and then replace it through my function. Commented Nov 11, 2013 at 21:45

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.