Skip to content

Instantly share code, notes, and snippets.

@frankschrijvers
Forked from GaryJones/functions.php
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frankschrijvers/7d36bf300f0622246362 to your computer and use it in GitHub Desktop.
Save frankschrijvers/7d36bf300f0622246362 to your computer and use it in GitHub Desktop.
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