I think you are searching for this: http://codex.wordpress.org/Function_Reference/wp_count_posts
<?php
$count_posts = wp_count_posts();
$draft_posts = $count_posts->draft;
?>
Related Posts:
- Pass media upload value to input field
- What does the token %1$s in WordPress represent [closed]
- Experiences with compiling WordPress using Hip Hop?
- WordPress redirect to landing page if not logged in
- PHP/Manual use of images? – 2 Questions
- Custom Yoast Breadcrumbs URL
- Debugging upload problem: What part of WP does actual image-resizing?
- Remove class that has been added by parent theme
- How to use a frontend URL with a Plugin
- Get list of shortcodes from content
- Adding Google Analytics code to the tag of specific pages
- Site Health : An active PHP session was detected
- login wp impossible
- Custom image upload
- How to scale image with equal width and height without distortion?
- How to display recent posts on home page with custom HTML
- Create Logout Link WordPress Admin Menu
- PHP 5.5, w3 Total Cache, and opcache [closed]
- How do I add text in a shortcode?
- How to display php source code inside a post using visual editor?
- PHP in post content [closed]
- Display post image with fancybox
- Attaching a pdf to Contact Form 7 e-mail via functions.php [closed]
- WordPress – how to replace with string on the_content() in single.php
- Getting array of customizer settings
- Ajax – Call to undefined function get_option()
- Display PHP within HTML values
- Show full posts in archive
- WordPress 3.2 query_posts and pagination, permalinks issue
- User management system similar to wordpress one?
- Implement One Time URL Script
- Call to undefined function wp() in wp-blog-header.php
- How does WordPress know wich language is chosen when there is a database connection error
- populate form fields in a loop with ajax
- How to pass Select value from Javascript to PHP to generate select option on change
- Recent Posts Not Showing Only On A Specific Category Page [closed]
- Contact form won’t submit
- Shortcode with PHP issue “Undefined index”
- Using same variable names in files added with get_template_part()
- Asynchronous multiple requests 401 Unauthorized
- Get the URL of the page from which an ajax request has been launched within ajax callback
- Edit the_category (); for a hierarchical display
- WordPress archive page showing 404 Error [duplicate]
- Division by zero error in image.php
- How to have different header.php based on the user logged in?
- How do I remove a category from a wordpress loop>
- How do I include SVG file used as featured image?
- Return product description
- How to add the sidebar to all the pages except the home page? [closed]
- Header not properly displaying on archive.php
- is_page_template showing partial results
- WordPress loop by meta key that is an array? and how loop multiple arrays
- Adding regular php file to site
- ACF & Bootstrap Gallery Shows Blank Slides [closed]
- REST API works in browser and via AJAX but fails via cURL
- How to display different submenus?
- Remove slugs from custom posts type
- Simple jQuery AJAX Request fails to run PHP Script
- Update if post with specific title exists
- child parent styles enqueue order
- Pass important values server-side when processing form
- Wp_editor doesn’t send the required data
- pass html code to worpdress
- Use an anchor link to open an iframe inside a WordPress page
- Can ‘Custom Field’ data be inserted into this Short Code?
- In WordPress, how do you make several different editors for a single page?
- Merge 2 product attribute terms
- How do I reset $wp_query in a function?
- Add class to all img if they have a certain ACF field
- How can I check that the acf field value is not a duplicate when adding a post?
- Run do_shortcode on php template using JS function
- global $product is empty string when passed into function
- How to update custom fields when post is published?
- Gravity Forms: How to add PHP function to confirmation conditional shortcode?
- wpdb->query returns different value to phpMyAdmin
- Trouble Accessing Gravity Forms API (GFAPI)
- How do I stop an Image Address from loading in the Browser?
- Add class to image in php
- Add a default style if no Featured image is selected
- When to use wp_register_script() function?
- setcookie() issues on running with HTTPS on WordPress
- loading a php file to a specific page id
- missing admin bar and widget in a template
- How to load WP_Editor JS files manually (with AJAX)?
- My own theme’s custom widget areas are not working
- How can I enqueue comment-reply script only on certain page?
- Querying posts from wordpress with 2 or more conditionals
- Importing demo data in Multisite
- Allow BBPress participant role to trash topics
- Posts with Custom Fields does not appear
- How to export database correctly for local to online
- Replace TinyMCE with Custom Built Editor
- Setting field not saving on front-end
- Getting custom field data from cart page to checkout page in woocomerce [closed]
- PHP Use Declared array Variable inside already Declared Array
- php grabbing every post made?
- Running a php code after User clicks a button? [closed]
- seo meta description issue in google search
- Redirect loop upon installation of my plugin
- PHP Works only for logged in users: [closed]