Add star rating to post info
.star-icon {
color: #ddd;
font-size: 18px;
position: relative;
}
.star-icon.full:before {
text-shadow: 0 0 2px rgba(0,0,0,0.7);
color: #FDE16D;
content: '\2605'; /* Full star in UTF-8 */
position: absolute;
left: 0;
}
.star-icon.half:before {
text-shadow: 0 0 2px rgba(0,0,0,0.7);
color: #FDE16D;
content: '\2605'; /* Full star in UTF-8 */
position: absolute;
left: 0;
width: 50%;
overflow: hidden;
}
@-moz-document url-prefix() { /* Firefox Hack :( */
.star-icon {
font-size: 18px;
line-height: 24px;
}
}
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
add_filter( 'genesis_post_info', 'jmw_add_star_rating_to_post_info' );
function jmw_add_star_rating_to_post_info( $filtered ) {
$star_rating = get_post_meta( get_the_ID(), 'star_rating', true );
if( !empty ( $star_rating ) ) {
$stars = '';
for( $i = 1; $i < 6; $i++ ) {
$class = '';
if( $i <= $star_rating ) {
$class = "full";
}
else if( $i < $star_rating + 1 ) {
$class = "half";
}
$stars .= sprintf( '<span class="star-icon %s">☆</span>', $class);
}
$filtered = sprintf( '<span class="star-rating">%s</span>%s', $stars, $filtered );
}
return $filtered;
}