To get the custom post types you would call the get_post_types
function.The built-in public post types are post, page, and attachment. By setting ‘_builtin’ to false, we will exclude them and show only the custom public post types. Below is the code.
<?php
$args = array(
'public' => true,
'_builtin' => false
);
$output="names"; // names or objects, note names is the default
$operator="and"; // 'and' or 'or'
$post_types = get_post_types( $args, $output, $operator );
foreach ( $post_types as $post_type ) {
$count_posts = wp_count_posts($post_type);
$published_posts = $published_posts+$count_posts->publish;
}
echo $published_posts;
?>
Related Posts:
- Add custom TinyMCE 4 Button, Usable since WordPress 3.9-beta1
- How to store username and password to API in wordpress option DB?
- Which hook should be used to add an action containing a redirect?
- Is it worth checking if class_exists when developing a plugin and how to do it?
- Default table collation on plugin activation?
- the_content after all shortcodes are parsed
- How to auto-upgrade my plugin?
- How do I resolve Notice: Undefined offset: 0 in /wp-includes/capabilities.php on line 1145
- Category listing with thumbnail and description on home page
- How can the tinyMCE dom be manipulated (offical API does not seem to work)?
- Pass javascript result to shortcode executer function
- URLs of plugin resources?
- anything like add_meta_box for categories?
- Can we create a category list page in WordPress?
- How to include class from addon after to be sure one class exists in the main plugin?
- Developing a plug-in to charge for
- WordPress: After Gutenberg plugin migration to block.json the localization/ translations with PolyGlot in JavaScript does not work anymore
- What is the Difference between directly call a function and call a function using add_action?
- What is better way to use Bootstrap inside admin panel?
- Updating my plugin without releasing a new version
- Is it possible to check is loaded language files correctly with WordPress plugin?
- 404 errors after plugin options update and category base change
- Default category got deleted. How to get it back as ID=1?
- How to determine, from plugin script, if active theme has The Post Title
- Order properties should not be accessed directly
- How to display additional info in the plugins admin table?
- Where to store the name of a custom table?
- Backbone event attachment:compat:ready can’t hook
- Add a class to a dynamic sidebar’s wrapper
- Limit role to one plugin [duplicate]
- How to fix Uninitialized string offset: error on a checkbox in WP Settings API
- Upgrade private plugin without deleting files?
- Saving value of a selection option in comment form as comment meta
- Is there some way to provide the user a list of existing content in a CPT
- Issue with querying
- how to search users by ajax live search
- Is this best practice for Dynamically adding items to WordPress menus?
- There is a problem in the gutenberg block I developed. Problem is with withInstanceId
- Detect front-end pages only in init hook
- best way to make a WordPresss multisite that is secure but at the same time supporting my plugin development efforts
- How to change title tag at page after loaded post?
- How to get post content by get_posts function?
- Getting following web services error after activating the Rewards Plugin
- WordPress custom taxonomy check box to dropdown
- Creating Admin Plugin – Content of a page is displayed at global scope as well
- How to remove plugin-specific custom taxonomy terms when plugin is uninstalled?
- How to modify files inside wp-includes directory in wordpress
- Fatal error: Call to a member function get_page_permastruct() on a non-object
- add_submenu_page hooked function must explicitly check user capabilities – why?
- How to apply style_loader_src filter with exclusion of a specific file?
- Which is the better way to store images for the plugin?
- Issue on Checkbox with Custom Option Page
- Minimum Widget Width for Plugin Development
- Should I use wp-content/cache or [PLUGIN_DIR]/cache?
- configuration of .htaccess for add_rewrite_rule to make sense
- Restrict certain actions to plugin-specific admin menu pages only
- How to get post meta in functions?
- Adding tables to dashboard pages programmatically?
- Plugin access to average users not only admin
- how to add custom fields into new & update post page?
- Custom Endpoint – Does it possible to use PUT method with WP API Rest?
- List all user post API endpoint
- Rewrite not working since upgrade to 5.9
- Condition to check previous next article post title
- How to display plugin with javascript using markup of the theme?
- Can display plugin without shortcode?
- ACF Field value in wordpress login message filter
- How to prevent wp_insert_post from creating a new post every second?
- Hook for validating and rejecting frontend image upload
- Plugin removes itself if mistake made during edit
- Using meta_key & meta_value in add_rewrite_rule
- Multisite and the JSON REST API: How to?
- Can’t create a blank template
- Custom Registration Form and Passwords
- Looping single post in a theme
- WP Ajax on page load not working on bluehost but was working on Godaddy
- Fullwidth slider using background image Flexslider WordPress
- Is there a way to tell if a shorcode’s handler is being run before or after the content formatting filter?
- How to create an embedded code for wordpress shortcode?
- How can I send an id over the url?
- grouping my widgets wordpress
- Creating custom Insert Media page
- Get fields of a widget
- How to add additional field in a table row after creating a table?
- WordPress plugin tables become corrupt
- Initialize class inside plugin
- How can i call from custom fields to the category editor?
- “Print to printer” functionality in a plugin
- How do you filter get_media_items by mime type in a custom media upload tab?
- Is it possible to convert various image types from remote URLs to WebP and then serve them immediately?
- Which subset of html does WordPress support?
- How to set init for maximum script execution, memory limit and max files upload in wordpress
- Trying to build a plugin – Cannot modify header information
- Help interpreting @wordpress/create-block-tutorial-template usage error
- Leveraging Core Functionality in Icon Upload Plugin [closed]
- esc_url, esc_url_raw or sanitize_url?
- React Plugin Settings Page Localization
- Is it within WordPress guidelines to update another plugin’s database fields from my own plugin? [closed]
- Block Development: hamburger module throwing error in save function
- How can I chanage the user for the composer container in wp-env?