0

i have a gallery of images withbutton for each when button for a image is click i want the custom field called count be updated with the newcount ...but form method is not working below is my code

PHP Code:

<? if (isset($_POST['submit'])) {  
echo " button clicked"; 
update_field('field_55014',$newcount,$postid);  
} 
?> 

<?php  
// Query the custom post type to display 
   $i=0;     
    $args = array('post_type' => 'books'); 
    $query = new WP_Query( $args ); 
    while ( $query->have_posts() ) :  
             $query->the_post(); 
                 if ( has_post_thumbnail() ):  
            $postid = get_the_ID(); 
            $oldcount=get_field('count'); 
            $newcount=$oldcount+1; 
            $i++; 
?> 
    <form action="#" method="post"> 
    <div><?php the_post_thumbnail('thumbnail'); ?><input type="submit" name="submit" value="Vote" /><?php echo " ".$oldcount;?></div> 
    </form> 

<?php endif; endwhile; ?>
1
Contributor
1
Reply
20
Views
2 Years
Discussion Span
Last Post by Neha_13
0

hat i want it that count increase and new value be updated on the page too.

plz not the code above is page-template.php assigned to page in wordpress.

when i change <form action="#" method="post"> to <form action=" page-template.php " method="post"> instead of refreshing and updating the current page it instead goes to page-template.php and returns a 404 error also the countis not update basically the if (isset($_POST['submit'])) part is not executed at all. plus it echose button clicked on pageload without clicking any button

Edited by Neha_13

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.