emm…
lets first define the $votes in your template, start by zero, then, use a code like this to save new votes:
update_post_meta($id, ‘_votes’, $votes);
now you added a the votes count to the database, to retrieve the count, replace the query loop with this query:
query_posts(‘meta_key=_votes&orderby=meta_value&posts_per_page=5’);
just like that :), no plugin needed. happy new year…
Thanks Khalid but i dont know if i get what youre saying. The plugin is more complex than just a click and update the vote count; it has ip control, ajax to avoid reloading the page and a couple of things more. I cant just replace it by a simple click-vote system if that os what you mean…
ya you are right, my code is just to replace the $wpdb part, however you still need to solve this other issues.
I dont get what “other issues” are you talking about.
i’m not coder, i just like php, may be i explain it wrongly, so plz forgive me.
i guess your code should have three parts:
1. check if the user have voted before, else he can vote.
2. after user votes you need to update records, and reorder posts.
3. reorder posts according to votes.
for me, i thought “update_post_meta($id, ‘_votes’, $votes);” will be much easier than the “$wpdb” route, so i was addressing the third part only.
Oh, i get now. Thanks Khalid, but thats not what im looking for.