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

Looking to replace static string text in this function with dynamic text from a var.

Current model:

  comments_number( 'no responses', '1 response', '% responses' );

Ideal Outcome (code guess):

  comments_number( '$no_responce_text', '1'.$responce_text, '%'.$responce_text );

I am sure this is an easy php question but stumped here.

Any help would be nice.


share|improve this question
up vote 0 down vote accepted

This should do it:

   sprintf('1 %s', $responce_text), 
   sprintf('%% %s', $responce_text)

Use get_comments_number if you want it properly localized.

share|improve this answer
There is one issue is with the last part, it is only outputting 2s (2 being a number greater than 1). Any thoughts on how to output the text with it? Does it have to do with the two %? – estern23 Sep 18 '11 at 13:40
yes, the first %s needed to be escaped, fixed it. – onetrickpony Sep 18 '11 at 13:41
Perfect! that did the trick! thanks for the help – estern23 Sep 18 '11 at 13:42

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.