Add wp_count_posts().

git-svn-id: http://svn.automattic.com/wordpress/trunk@6730 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan
2008-02-05 19:08:14 +00:00
parent b67bbb9e4e
commit b85271e8ed
2 changed files with 23 additions and 4 deletions

View File

@@ -789,6 +789,25 @@ function sanitize_post_field($field, $value, $post_id, $context) {
return $value;
}
/**
* wp_count_posts() - Count number of posts with a given type and status
*
* {@internal Missing Long Description}}
*
* @package WordPress
* @subpackage Post
* @since 2.5
*
* @param string $type Post type
* @param string $status Post status
* @return int Number of posts
*/
function wp_count_posts( $type = 'post', $status = 'publish' ) {
global $wpdb;
return $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = %s AND post_status = %s", $type, $status) );
}
/**
* wp_delete_post() - Deletes a Post
*