Support » Fixing WordPress » printf weirdness with comment_author_link

  • Resolved fouriertransform


    Hi all,

    printf is driving me insane. Whenever is use it, the string being called up appears at the front of the returned output no matter where it appears in the formatting string. This could be worked around were it not for the fact that I’m using Polyglot to translate between two languages, so I need the string location to be different in each language – it always appears at the front though.

    If in my comments template I write:

    printf('Here is what %s said:', comment_author_link());

    I get the output:
    AuthorHere is what said:

    Which is no good.

    printf obviously works, because the following:

    printf('Here is what %s said:', 'Geoff');

    gives me, as expected,
    Here is what Geoff said:

    So comment_author_link is doing weird stuff and pushing itself to the front of the queue. Why? And how do I make it stop? I can’t see anything in comment_functions.php to make it do that, but then I no php expert.

    Any help appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • PHP 101: Do not pass functions through other functions which echo or print their held value.

    Instead of comment_author_link(), which displays the url of a commenter, try:

    printf('Here is what %s said:', get_comment_author_link());

    (get_comment_author_link() does exactly what comment_author_link() does, but returns rather than echoes the value it holds).

    That is beautiful – and lightning fast! I have a lot to learn…

    Thank you so much 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘printf weirdness with comment_author_link’ is closed to new replies.