Changeset 6730
- Timestamp:
- 02/05/2008 07:08:14 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/index.php
r6705 r6730 38 38 39 39 <?php 40 $num_posts = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish'");40 $num_posts = wp_count_posts('post', 'publish'); 41 41 42 $num_pages = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'page' AND post_status = 'publish'");42 $num_pages = wp_count_posts('page', 'publish'); 43 43 44 $num_drafts = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'draft'");44 $num_drafts = wp_count_posts('post', 'draft'); 45 45 46 $num_future = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'future'");46 $num_future = wp_count_posts('post', 'future'); 47 47 48 48 $num_comments = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'"); -
trunk/wp-includes/post.php
r6726 r6730 791 791 792 792 /** 793 * wp_count_posts() - Count number of posts with a given type and status 794 * 795 * {@internal Missing Long Description}} 796 * 797 * @package WordPress 798 * @subpackage Post 799 * @since 2.5 800 * 801 * @param string $type Post type 802 * @param string $status Post status 803 * @return int Number of posts 804 */ 805 function wp_count_posts( $type = 'post', $status = 'publish' ) { 806 global $wpdb; 807 808 return $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = %s AND post_status = %s", $type, $status) ); 809 } 810 811 /** 793 812 * wp_delete_post() - Deletes a Post 794 813 *
Note: See TracChangeset
for help on using the changeset viewer.