Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Style the Genesis comment count number
<?php
// Don't include above <?php
add_filter( 'genesis_post_comments_shortcode', 'prefix_post_comments_shortcode' );
/**
* Amend the post comments shortcode to add extra markup for styling.
*
* @author Gary Jones
* @link http://gamajo.com/style-comment-number/
*
* @param string $output HTML markup.
*
* @return string HTML markup.
*/
function prefix_post_comments_shortcode( $output ) {
return preg_replace( '/#comments"\>(\d+) Comment/', '#comments"><span class="entry-comments-number">$1</span> Comment', $output );
}
<?php
// Don't include above <?php
add_filter( 'genesis_post_info', 'prefix_post_info' );
/**
* Filter the post info line.
*
* Copies the default output and changes it to include a `zero` attribute for the post_comments shortcode.
*
* @author Gary Jones
* @link http://gamajo.com/style-comment-number/
*
* @param string $output HTML markup, likely with shortcodes.
*
* @return string HTML markup.
*/
function prefix_post_info( $post_info ) {
return '[post_date] ' . __( 'by', 'textdomain' ) . ' [post_author_posts_link] [post_comments zero="0 Comments"] [post_edit]';
}
<span class="entry-comments"><!-- class will be post-comments for XHTML child themes -->
<a href="http://example.com/post-name/#comments"><span class="entry-comments-number">1</span> Comment</a>
</span>
.entry-comments-number {
font-size: 16px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment