How to count custom post types in wordpress

How to count custom post types in wordpress

You have custom post types in your wordpress website, and want to count them for different purposes? Well, here is a fast and simple solution on how you can do it.

[php]

<?php
$count_posts = wp_count_posts(‘portfolio’)->publish; //replace portfolio with your custom post type
echo $count_posts; //output the number of posts
?>

[/php]

Leave a reply

0
Connecting
Please wait...
Send a message

Sorry, we aren't online at the moment. Leave a message.

Your name
* Email
* Describe your issue
Chat now

Need more help? Save time by starting your support request online.

Your name
* Email
* Describe your issue
We're online! Ask us anything!
Feedback

Help us help you better! Feel free to leave us any additional feedback.

How do you rate our support?