<?php
/**
* Single Post Template
*
* This template is the default page template. It is used to display content when someone is viewing a
* singular view of a post ('post' post_type).
* @link http://codex.wordpress.org/Post_Types#Post
*
* @package WooFramework
* @subpackage Template
*/
get_header();
?>
<!-- #content Starts -->
<?php woo_content_before(); ?>
<div id="content" class="col-full">
<div id="main-sidebar-container">
<!-- #main Starts -->
<?php woo_main_before(); ?>
<div id="main">
<?php
woo_loop_before();
if (have_posts()) { $count = 0;
while (have_posts()) { the_post(); $count++; ?>
<div id="productpic"><?php the_post_thumbnail(); ?></div>
<p class="summary"><?php woo_get_template_part( 'content', get_post_type() ); ?></p>
<div id="ratingtitle"><p>AVERAGE STAR RATINGS</p></div>
<?php function percentage($val1, $val2, $precision)
{
$division = $val1 / $val2;
$res = $division * 100;
$res = round($res, $precision);
return $res;
} ?>
<div id="score"><p>OVERALL SCORE</p><div id="percent"><?php echo percentage(get_post_meta($post->ID, 'averagerating_rc', true), 5, 0); ?>%</div></div>
<div id="vendor">Vendor / Manufacturer: <?php echo get_post_meta($post->ID, 'Vendor', true); ?></div>
<a id="urlquotebox" href="<?php echo get_post_meta($post->ID, 'vendorweb', true); ?>" target="blank">Vendor Product Page</a>
<?php global $post;
$current_post = $post->ID;
$categories = get_the_category();
foreach ($categories as $category) :
?>
<div class="my-related-posts"><h4>You may also be interested in...</h4><ul class="relatedposts">
<?php
$duplicates = array( $current_post );
$posts = get_posts( array( 'posts_per_page' => 4, 'orderby' => 'rand', 'category' => $category->term_id, 'post__not_in' => array( $current_post )) );
$second_numbers = (!$posts) ? 4 : (4 - count( $posts ));
if( $posts ) :
foreach($posts as $post) :
setup_postdata( $post );
$duplicates[] = $post->ID;
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ));
?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?><br /><img src="<?php echo esc_url( $image[0] ); ?>" alt="View more info" /></a></li>
<?php endforeach; wp_reset_postdata();
endif;
if( $second_numbers >=1 ) :
$posts = get_posts( array('posts_per_page' => $second_numbers, 'orderby' => 'rand', 'post__not_in' => $duplicates ) );
if( $posts ) foreach($posts as $post) :
setup_postdata( $post );
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ));
?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?><br /><img src="<?php echo esc_url( $image[0] ); ?>" alt="View more info" /></a></li>
<?php endforeach; wp_reset_postdata();
endif; ?>
</ul>
</div>
<?php
}
}
woo_loop_after();
?> <h3 class="commentstitle">USER REVIEWS</h3>
</div><!-- /#main -->
<?php woo_main_after(); ?>
<?php get_sidebar(); ?>
</div><!-- /#main-sidebar-container -->
<?php get_sidebar('alt'); ?>
</div><!-- /#content -->
<?php woo_content_after(); ?>
<?php get_footer(); ?>