Last active
June 24, 2017 19:40
-
-
Save GaryJones/1708175 to your computer and use it in GitHub Desktop.
Style the Genesis comment count number
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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]'; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.entry-comments-number { | |
font-size: 16px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment