October 5

How to count custom post types in wordpress

0  comments

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]

Tags

count, custom, post, types, wordpress


You may also like

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Get in touch

Name*
Email*
Message
0 of 350