WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I can change label of comments by altering Comment(s) from parameter of following function: comments_popup_link('No Comments;', '1 Comment;', '% Comments;'); But, seems that title attribute is returned from core modules. Suggest me to alter title attribute without editing core modules.

share|improve this question
Have you tried using localization to change that? An .mo file doesn't need to have more than one string in it... You could create a custom .mo file that "translates" the string 'Comment on %s' to whatever you want it to say... – goldenapples Aug 20 '11 at 17:55
up vote 2 down vote accepted

If you look into the function comments_popup_link() you will see the following code at the end:

$title = the_title_attribute( array('echo' => 0 ) );

echo apply_filters( 'comments_popup_link_attributes', '' );

echo ' title="' . esc_attr( sprintf( __('Comment on %s'), $title ) ) . '">';
comments_number( $zero, $one, $more );
echo '</a>'; // last line

Note the call to __(), the translation function. We can filter 'gettext' to change the result. Since we do not want to run our filter on every translation – that would be too slow – we start the filter when the hook 'comments_popup_link_attributes' is called:

add_filter( 'comments_popup_link_attributes', 't5_cclta_init' );

function t5_cclta_init( $attrs )
    add_filter( 'gettext', 't5_cclta_change_title', 10, 3 );
    return $attrs;

Now we need just the real filter function:

function t5_cclta_change_title( $translated, $text, $domain )
    remove_filter( current_filter(), __FUNCTION__, 10 );

    if ( 'default' === $domain && 'Comment on %s' === $text )
        return 'Talk about %s';

    return $translated;

And now the title attribute says: Talk about The Post Title.

share|improve this answer

Like they said it's hard coded into WP core, and it's best practice to not mess with the core. However the title is located in <span class="screen-reader-text">Post Title</span> just use CSS to hide it.

.screen-reader-text{ display: none; }

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.