Add wp_count_posts().
git-svn-id: http://svn.automattic.com/wordpress/trunk@6730 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
b67bbb9e4e
commit
b85271e8ed
|
@ -37,13 +37,13 @@ $today = current_time('mysql', 1);
|
|||
<h3 class="reallynow"><?php _e('Right Now'); ?> <a href="post-new.php" class="rbutton"><?php _e('Write a New Post'); ?></a> <a href="page-new.php" class="rbutton"><?php _e('Write a New Page'); ?></a></h3>
|
||||
|
||||
<?php
|
||||
$num_posts = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish'" );
|
||||
$num_posts = wp_count_posts('post', 'publish');
|
||||
|
||||
$num_pages = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'page' AND post_status = 'publish'" );
|
||||
$num_pages = wp_count_posts('page', 'publish');
|
||||
|
||||
$num_drafts = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'draft'" );
|
||||
$num_drafts = wp_count_posts('post', 'draft');
|
||||
|
||||
$num_future = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'future'" );
|
||||
$num_future = wp_count_posts('post', 'future');
|
||||
|
||||
$num_comments = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'");
|
||||
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue