I'm trying to get the count of published posts in a custom post type for the current user (to display on a profile page).
I found this here on the forums:
<?php global $wp_query; $curauth = $wp_query->get_queried_object(); $post_count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '" . $curauth->ID . "' AND post_type = 'user_video' AND post_status = 'publish'"); ?>
But, it's just giving me a big fat ZERO even though there are definitely published posts of that type. What am I doing wrong and is there a better way to do this?