WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In an author.php template, i count the author post in a custom post type with $wpdb->get_var,

$post_author = $curauth->ID; //author id
$count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = $post_author AND post_type IN ('ideas') and post_status = 'publish'" );

is it possible to count the author, total votes saved in post meta with key 'votes'?
the value for every post is a number updated each time a user votes a post


share|improve this question
up vote 1 down vote accepted

This wouldn't be possible unless you keep a log of users that have voted the Idea. You will have to create another hidden post_meta array which will store a list of all the users who have voted the Idea. In that way you could count the number of votes an author has given. Or better yet you could create and update the user_meta 'ideas_voted' when a particular idea is voted by a user.

if ( idea is voted ) {
    $ideas_voted = ( get_user_meta( $curauth->ID, 'ideas_voted' ) ) ? get_user_meta( $curauth->ID, 'ideas_voted' ) + 1 : 1;
    update_user_meta( $curauth->ID, 'ideas_voted', $ideas_voted );
share|improve this answer
thanks a lot @Joshua! – Philip Dec 10 '11 at 12:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.