Skip to content

Instantly share code, notes, and snippets.

@mzalewski
Last active April 21, 2017 00:47
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 mzalewski/32c8fff473192a0e42ac3c422a760a91 to your computer and use it in GitHub Desktop.
Save mzalewski/32c8fff473192a0e42ac3c422a760a91 to your computer and use it in GitHub Desktop.
Code Snippet showing Score in post content
add_filter( 'the_content', 'add_review_score_content' );
function add_review_score_content( $content ) {
global $post;
if ( ! is_singular() || $post->post_type !== 'reviews' )
{
// It's not a single Review so just return standard content
return $content;
}
$score_value = esc_html( get_field( 'score' ) );
$score = '<hr /><h3>Our Score: <span class="score" style="float:right;font-weight:bold">' . $score_value . ' / 100</span></h3>';
return $content . $score;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment