RBA Cash Rate: 4.35% · 1AUD = 0.67 USD · Inflation: 4.1%  
Leading Digital Marketing Experts</strong | 1300 235 433 | Aggregation Enquires Welcome | Book Appointment
Example Interest Rates: Home Loan Variable: 5.69% (5.89%*) • Home Loan Fixed: 5.39% (6.59%*) • Fixed: 5.39% (6.59%*) • Variable: 5.69% (5.89%*) • Investment IO: 5.69% (6.48%*) • Investment PI: 5.39% (6.59%*)

Count WordPress Posts

This was one of the shortcodes we ever shared to count the number of WP posts. For a more robust function, see this article.

1
<?php 
2
/*
3
 Count number of posts
4
 http://www.beliefmedia.com/code/wp-snippets/count-wp-posts
5
*/
6
 
7
function beliefmedia_number_pub_posts() {
8
 return wp_count_posts()->publish;
9
}
10
add_shortcode('numberposts', 'beliefmedia_number_pub_posts');

To count other post types, see this page . For example, you might count drafts as $count_posts->draft; and pages as wp_count_posts('page');.

The wp_count_posts() can be used to find the number for post statuses of any post type. This includes attachments or any post type added in the future, either by a plugin or part of the WordPress Core.

■ ■ ■

 
Download our complimentary 650-page guide on marketing for mortgage brokers. We'll show you exactly how we generate billions in volume for our clients.
Finance Guide, Cropped Top and Bottom
  Timezone: 1 · [ CHANGE ]

Like this article?

Share on Facebook
Share on Twitter
Share on Linkdin
Share on Pinterest

Leave a comment