Getting post ID in WP query
-
I’m trying to display the total number of votes for each blog post. I’m getting the vote number for each post from a custom “votes” table.
$vote_results = $wpdb->get_row("SELECT * FROM $vote_table WHERE vote_post_id = $post_ID"); echo $vote_results->votes; //echoes nr of votes
The issue: $post_ID doesn’t output the post ID from blog posts that I need to compare with the votes table.
The query works fine when I manually enter a post ID.
Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
- The topic ‘Getting post ID in WP query’ is closed to new replies.