The Genesis Framework bundles a number of useful shortcodes that allow you to access and output important pieces of information quickly. One of these produces the number of comments on a Post or Page and makes it clickable to the comments section.
The shortcode to produce a clickable comments link is
This shortcode is employed by default in the entry meta, but you can actually use it wherever you like, such as the Post or Page title, the Post or Page body or the entry meta after the content.
As an example, below is the code to display the clickable author link after the content instead of before the content.
You can use the
after attributes to add extra text immediately before or after the clickable comments link.
You can use the
more attributes to customize the text of the link depending on how many comments there are. For more, use the % symbol in place of the number.
before – Text to insert immediately before the clickable comments link.
after – Text to insert immediately after the clickable comments link.
zero – The main text to display if there are no existing comments.
Default: Leave a Comment
one – The main text to display if there is one comment.
Default: 1 Comment
more – The main text to display if there is more than one comment, with the % symbol in place of the number.
Default: % Comments
hide_if_off – If the value of this attribute is
enabled, the clickable comments link is abandoned if comments are closed.
[post_comments] outputs the following in order:
<span class="entry-comments-link">(HTML5) or
- the text passed to the before attribute, if any
<a href="#">, where
#is the link to the comments section
- the main text, depending on how many comments there are
- the text passed to the after attribute, if any
There is one filter on the output of this shortcode, which is
genesis_post_comments_shortcode. The entire marked up comments link passes through this filter before being output.
Genesis Simple Edits
[post_comments] has been included since version 1.1.0.
[post_comments] is located in lib/shortcodes/post.php.