Make WordPress Core


Ignore:
Timestamp:
02/05/2008 07:08:14 PM (17 years ago)
Author:
ryan
Message:

Add wp_count_posts().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post.php

    r6726 r6730  
    791791
    792792/**
     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 */
     805function 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/**
    793812 * wp_delete_post() - Deletes a Post
    794813 *
Note: See TracChangeset for help on using the changeset viewer.