Blog Archives

Rate your post without wordpress plugin.

Simple way to Rate your post without wordpress plugin

in single post insert the code below.

<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); ?>

I hope you will have idea about it.

decorate submit button up and down with some backgound image like thumb down and thumb up image.

to filter top rated post use the query given below.

query_posts('&meta_key=up&orderby=meta_value_num&order=DESC');
Design a site like this with WordPress.com
Get started