I've been trying to figure this out for a while now. So I'm trying to add a custom field call "counter" to every single post. I try simply inserting the field "counter" to the post table. Every time a user clicks a button on the post, it increments the counter So far so good.
But now the tricky part is being able to get back the information with WP_Query. I want to do a custom query for posts where the counter is greater than 0, loop through the posts, and display them with template tags.
If i were to write an sql stamens it would look like this
$query = "SELECT * FROM $wpdb->post WHERE counter > 0";
But I can't do a normal SQL query because then I won't have access to template tags such as Wordpress's "show next page | show older page" template tags.
I'm not looking for a plugin but I'm trying to find a way that i can add a field to the post table and be able to query the posts base on the custom fields, loop through the result, and display the information about the post. If you guys have any suggestions, I would really appreciate it.
Note: Am i suppose to add the custom field to post meta? Looking at the SQL table, it doesn't seem like a right place to do it...