i have a page template assigned to a page, that displays the images of all the posttype=suspense...but how do i get voting button on each of the image so that ppl can vote on each image and restrict it to voting per ip.
i have a custom field called count that i want to store the votes to and updatenext to image immediately...just cant seem to get it to work
here's my code
<?php
/**
* Template Name: suspense Gallery
*
* Description: Creates a gallery of featured images from a custom post type
*
* @package WordPress
* @subpackage
* @since 2014
*/
?>
<script>
function myvote($pid,$tempcount) {
$sql = "UPDATE `count` SET count = '$tempcount' WHERE post_id = $pid";
$query = mysql_query($sql);
}
</script>
<?php
// Query the custom post type to display
$args = array('post_type' => 'suspense');
$query = new WP_Query( $args );
while ( $query->have_posts() ) :
$query->the_post();
if ( has_post_thumbnail() ):
?>
<div><?php the_post_thumbnail('thumbnail'); ?><button onclick="myvote($post->ID,$newcount)">Vote</button><?php echo get_field('count');?></div>
<?php endif; endwhile; ?>