Skip to content

Instantly share code, notes, and snippets.

@MikeGillihan
Created December 26, 2017 22:15
Show Gist options
  • Save MikeGillihan/b163614d588d1d70393546475e3a3656 to your computer and use it in GitHub Desktop.
Save MikeGillihan/b163614d588d1d70393546475e3a3656 to your computer and use it in GitHub Desktop.
Filter the output of the HeartThis for the front page
add_filter( 'heart_this_hearts', 'custom_heart_this_hearts' );
/**
* Filter the output of the HeartThis for the front page
*
* @param $output
* @param bool $post_id
*
* @return string
*/
function custom_heart_this_hearts( $output, $post_id = false ) {
if ( ! $post_id ) {
$post_id = get_the_ID();
}
$output = sprintf( '<a href="#" class="heart-this" id="heart-this-%s" data-post-id="%s"><span>%s</span>%s</a>',
uniqid(),
$post_id,
number_format_i18n( heart_this_get_meta( $post_id ) ),
is_front_page() ? ' <i class="fa fa-heart"></i>' : ''
);
$output = sprintf( '<span class="heart-this-wrap">%s</span>', $output );
return $output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment