I am using WooTheme's Canvas theme and would like to "hardcode" in the [post_comments] shortcode into my theme. [post_comments] displays a comment link with comment count (ie Comments 10) in my post. Right now I am inserting the [post_comments] shortcode into my theme's meta "Meta Manager"; however, this is not ideal for me as I have limited control over the placement of where the this shows up in my post. What type of function or such should I be looking for to do this within my .php files?

Thank you


Check out do_shortcode(): http://codex.wordpress.org/Function_Reference/do_shortcode

do_shortcode('[shortcode option1="value1" option2="value2"]');

So your example would be:


What might be easier is to tap into the underlying comment functions:


  This post currently has
  <?php comments_number( 'no responses', 'one response', '% responses' ); ?>.

You can also use get_comments_number which returns the value rather than printing it to the screen.

This function however needs to be in the Loop for it to work, however I have a feeling it is.

  • Thanks for the reply.But this didn't seem to work. do_shortcode('[post_comments]'); I placed this in my content-post.php file – Brian Housman Jun 30 '11 at 17:38
  • Where is that shortcode defined, is it in the Canvas theme? – danielrsmith Jun 30 '11 at 21:14
  • Thanks! get_comments_number() is a great solution! I'm just going to add "Comments" text and wrap the number in "()". – Brian Housman Jun 30 '11 at 22:19
  • Yes, [post_comments] is defined within theme-shortcodes.php – Brian Housman Jun 30 '11 at 22:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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