Get Custom Post Type Post's Count
X

Congrats, You are Subscribed to Receive Updates.

Get Custom Post Type Post’s Count


Get Custom Post type posts count. This is a small snippet which will give you the count of your custom post type. Sometimes we need to show some count of published posts on a custom post type.  The following snippet will help you to get it.

$posts = get_posts('post_type=job');
$count = count($posts);
echo $count;

Also, you can get the count based on Post Status, The following snippet will get you the drafted post counts,

$posts = get_posts('post_type=job&post_status=draft');
$count = count($posts);
echo $count;

Likewise, you can get the count of publish, pending, trashed post counts.  also you can get the posts based on its author.  You can get Custom Post  type  count based on Author. The following snippet will help you to get it.

$posts = get_posts('post_type=job&post_author=1');
$count = count($posts);
echo $count;

likewise, you can get custom post type count.

commenter

About Varadharaj V

The founder of Kvcodes, Varadharaj V is an ERP Analyst and a Web developer specializing in WordPress(WP), WP Theme development, WP Plugin development, Frontaccounting(FA), Sales, Purchases, Inventory, Ledgers, Payroll & HRM, CRM, FA Core Customization, OpenCart Theme Development, PHP, HTML, CSS, jQuery, Bootstrap development and content SEO.

Comment Below

Your email address will not be published. Required fields are marked *

*

Current ye@r *

Menu

Sidebar

Subscribe E-mail Updates

Congrats, You are Subscribed to Receive Updates.

Advertisement

Category Posts