Ticket #5820: wp-includes-post.php.diff
| File wp-includes-post.php.diff, 1.1 kB (added by josephscott, 10 months ago) |
|---|
-
post.php
old new 790 790 } 791 791 792 792 /** 793 * wp_count_posts() - Count number of posts with a given type and status793 * wp_count_posts() - Count number of posts with a given type 794 794 * 795 795 * {@internal Missing Long Description}} 796 796 * … … 799 799 * @since 2.5 800 800 * 801 801 * @param string $type Post type 802 * @param string $status Post status 803 * @return int Number of posts 802 * @return array Number of posts for each status 804 803 */ 805 function wp_count_posts( $type = 'post' , $status = 'publish') {804 function wp_count_posts( $type = 'post' ) { 806 805 global $wpdb; 807 806 808 return $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = %s AND post_status = %s", $type, $status) ); 807 $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 ); 808 809 $stats = array( ); 810 foreach( (array) $count as $row_num => $row ) { 811 $stats[$row['post_status']] = $row['num_posts']; 812 } 813 814 return $stats; 809 815 } 810 816 811 817 /**
