Changeset 6808 for trunk/wp-includes/post.php
- Timestamp:
- 02/13/2008 09:30:26 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/post.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/post.php
r6803 r6808 783 783 784 784 /** 785 * wp_count_posts() - Count number of posts with a given type and status785 * wp_count_posts() - Count number of posts with a given type 786 786 * 787 787 * {@internal Missing Long Description}} … … 792 792 * 793 793 * @param string $type Post type 794 * @param string $status Post status 795 * @return int Number of posts 796 */ 797 function wp_count_posts( $type = 'post', $status = 'publish' ) { 794 * @return array Number of posts for each status 795 */ 796 function wp_count_posts( $type = 'post' ) { 798 797 global $wpdb; 799 798 800 return $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = %s AND post_status = %s", $type, $status) ); 799 $count = $wpdb->get_results( $wpdb->prepare( "SELECT post_status, COUNT( * ) AS num_posts FROM {$wpdb->posts} WHERE post_type = %s GROUP BY post_status", $type ), ARRAY_A ); 800 801 $stats = array( ); 802 foreach( (array) $count as $row_num => $row ) { 803 $stats[$row['post_status']] = $row['num_posts']; 804 } 805 806 return (object) $stats; 801 807 } 802 808
Note: See TracChangeset
for help on using the changeset viewer.