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

1 Answer
1

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

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

So your example would be:

do_shortcode('[post_comments]');

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

http://codex.wordpress.org/Function_Reference/comments_number

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

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.

Leave a Reply

Your email address will not be published. Required fields are marked *