Count tags for a specific category

count how many posts are tagged but only include those posts that belong to a specific category You can’t do that via get_terms(), but you can make a WP_Query query and use the $found_posts property to get the total posts. So for example, in your foreach, you can use the tag and cat parameters like … Read more

If x comments in a post move post to category y

You could use the wp_insert_comment action to detect when new comments are added to a post. Then on your action callback, you’d the post’s comment count with get_comments_number(), and change post categories with wp_set_object_terms(). Something along these lines, add_filter( ‘wp_insert_comment’, function($id, $comment) { if ( (int) $comment->comment_approved ) { $post_id = (int) $comment->comment_post_ID; $post_comment_count = … Read more

Best way to count visitors?

There are a number of ways of achieving this but the two ways I would concider would be Google analytics – http://wordpress.org/extend/plugins/google-analytics-for-wordpress/ WordPress Sitestats – http://wordpress.org/extend/plugins/stats/ or install http://wordpress.org/extend/plugins/jetpack/ as it comes with that.

Count posts published in one particular day: the lighter way

$wp_query->found_posts can be used to get the number of posts. But here are arguments you can use to optimize the query and avoid useless SQL retrievals: cache_results’ => false, // Turns off post caching ‘no_found_rows’ => true, // To optimize when pagination is not required ‘fields’ => ‘ids’ // To only retrieve IDs information, nothing … Read more

How to do simple addition to increase favorites count of my wordpress posts

You can simply do it by adding 300 when displaying count as shown in following code: <?php echo ‘TOTAL POST VIEWS: ‘ .(intval(wpfp_get_current_count()) + 300); ?> and instead of echoing that values in function return it as shown in following code: function wpfp_get_current_count() { global $wpdb; $current_post = get_the_ID(); $query = “SELECT post_id, meta_value, post_status … Read more

How many members have made comments approved for an article?

Your PHP is wrong but what you are doing looks like it should work. $count = $wpdb->get_var( ‘SELECT COUNT(distinct comment_author) FROM ‘ .$wpdb->comments. ‘ WHERE comment_approved = 1 AND comment_post_ID = ‘.$post->ID ); echo $count; Precisely, you were trying to use a variable inside single quotes, which doesn’t work. Variables don’t expand inside single quotes. … Read more

Count post + add number =

If you want to count posts of some custom post type, you can try out the WordPress function wp_count_posts() In your case the custom post type is ‘projects’ so you might try this: $count_projects = wp_count_posts( ‘projects’ ); $published_projects = $count_projects->publish; $total = $published_projects + 11; // include your additional projects You can read more … Read more

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