Count posts by type including drafts and pending posts

It’s not necessary to use $wpdb, a simple get_posts can handle it. Check WP_Query for the full list of parameters. function count_user_posts_by_type( $userid, $post_type ) { $args = array( ‘numberposts’ => -1, ‘post_type’ => $post_type, ‘post_status’ => array( ‘publish’, ‘private’, ‘draft’, ‘pending’ ), ‘author’ => $userid ); $count_posts = count( get_posts( $args ) ); return … Read more

Count comment threads, not total comments in a post

You could try this, must be used in the loop: <?php // type = comment will only get “real” comments, no ping-/trackbacks $comments = get_comments(array(‘type’ => ‘comment’)); $threads = 0; foreach($comments as $comment) { // if the comment has no parent, it´s the first of a thread if($comment->parent == ”) { $threads++; } } switch($threads) … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)