Total published pages counter (custom post type)

Hi there, I’m trying to find out if it’s possible to easily fetch (perhaps through pro your shortcodes) the counter of total published pages of a specific type. In this case, the post type I’m interested in is “waterfall”.

I have tried to generate several shortcodes through the looper consumer, but none returned the expected result. Therefore I had to write my own shortcode.

// Get post count for cpt
add_shortcode('postcount', 'post_count');
 function post_count() {
     $count_posts = wp_count_posts('waterfall');
     $published_posts = $count_posts->publish;
     return $published_posts . ' ';
} 

I would like to achieve the same result through the built-in shortcodes.

Hello @Tepepaz,

Thanks for writing in! Regretfully there isn’t a feature or or any dynamic content that returns the total number of published pages of a specific type. It is only possible with custom coding which I think your shortcode already covers for that.

Please note that custom coding is outside the scope of our support. Issues that might arise from the use of custom code and further enhancements should be directed to a third party developer.

Best Regards.

Hello @ruenel,
Thank you for your swift reply. It’s a pity that such a basic function wasn’t included among the possibilities of dynamic content. It would be nice to have the chance to build a custom query at least, but the WP Query does not support it either.

Unfortunately, I can’t use the shortcode I wrote within the cornerstone elements. My idea was to use it in the counter but it doesn’t work, indeed.

Hi @Tepepaz,

I tested your code above and add the shortcode in the Raw Content element then it is showing the count of my custom post type. I suggest that you do the same thing.

Hope that helps.

Thank you.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.