Filter
add_filter( 'the_content', 'sandy_posts_filter' );
function sandy_posts_filter( $content )
{
global $post;
$review_box_pos =get_post_meta( $post->ID, 'repeatable_fields', true );
if (is_array($review_box_pos)) {
foreach ($review_box_pos as $key => $val) {
switch ($val[nameooz]) {
case 'top':
$content = sandy_reviews() . $content;
break;
case 'bottom':
//$content .= "Extra Content" ; Work at footer Perfect//
$content .= sandy_reviews() ; //shown at top only !!!
break;
} //End Switch
}
}
return $content ;
}
Function
//////////////////// Reviews Box ///////////////////////
function sandy_reviews() {
$get_meta = get_post_custom($current_ID);
$reviews = (get_post_meta(get_the_ID(), 'repeatable_fields', true));
$sumArray = array();
if (is_array($reviews))
foreach($reviews as $k => $val) {
foreach($val as $id => $value) {
$sumArray[$id] += $value;
}
}
$Reviwes_count = count($reviews);
$Total_Reviwes = round(($sumArray[range] / $Reviwes_count), 1);
if (!empty($reviews)) { ?>
<div class = "reviews-box" >
<div class = "reviews-box-title" >
<?php
$get_meta = get_post_custom($current_ID);
if (!empty($reviews))
foreach($reviews as $val) {
echo $val["nameoo"];
} ?>
</div>
<?php
//Get Round Number
if (!empty($reviews))
foreach($reviews as $key => $val) {
if (!empty($val[range]))
$reviews_title = $val[nameoo];
$ranges = $val[range];
$range1 = ($val[range] * 0.01) * (5);
$range2 = floor(($range1 * 2) / 2);
$Reviwes = ($range1 * 20);
?>
<div class = "reviews-box-row" >
<div class = "reviews-box-keywords" > <?php echo $val[name]; ?> </div> <div class = "reviews-box-ranges" >
<span style = "display: block;float:left; width: 65px; height: 13px; background: url( <?php echo get_template_directory_uri();?>/images/star-rating-sprite.png) 0 0;" >
<span style = "display: block;float:left; width: <?php echo $ranges.'%';?>; height: 13px; background: url( <?php echo get_template_directory_uri();?>/images/star-rating-sprite.png) 0 -13px;" > </span> </span> <?php
echo "</div></div>";}
?>
<div class = "reviews-box-percent" > Summary </div>
<!-- <div class="reviews-box-ranges"><?php //echo ($val[range]*0.01)*(5);?></div> -->
<div class = "reviews-box-ranges-percent" >
<div class = "Total_Reviwes" > <?php echo $Total_Reviwes.""; ?> </div>
<span style = "display: inline-block; margin:0 auto;width: 65px; height: 13px; background: url( <?php echo get_template_directory_uri();?>/images/star-rating-sprite.png) 0 0;" >
<span style = "display: block; margin:0 auto;float:left;width: <?php echo $Total_Reviwes.'%';?>; height: 13px; background: url( <?php echo get_template_directory_uri();?>/images/star-rating-sprite.png) 0 -13px;" > </span> </span>
<?php
echo "</div>";
echo "</div>";
}
}
//////////////////// Reviews Box END///////////////////////
1- Why this function not shown at bottom of content ?
2- Why when we used this filter at top of content it’s show review box at
summary of content at category page !!
`