WordPress post rating without plugins?
-
Is there any simple post rating snippet which will work when page is cached. There is many functions, for example this:
<form method='POST' action=""> <input type=hidden name=rate value=up> <input type=submit value=submit> </form> <?php if(isset($_POST['rate'])) { if($_POST['rate']=='up') { $rate=get_post_meta($post->ID,'up',true); $rate=$rate+1; update_post_meta($post->ID,'up',$rate); } if($_POST['rate']=='down') { $rate=get_post_meta($post->ID,'down',true); $rate=$rate+1; update_post_meta($post->ID,'down',$rate); } } echo "UP:".get_post_meta($post->ID,'up',true); echo "DOWN:".get_post_meta($post->ID,'down',true); ?>
from rate your post without WordPress plugin. It works fine, BUT, only if user is logged in or site in not using any caching plugin like WP Super cache, or any other.
I guess it will need some java/Ajax script to work when page is cached?
- The topic ‘WordPress post rating without plugins?’ is closed to new replies.