Below is the code to display the total number of published posts using a shortcode.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Display the total number of published posts using the shortcode [published-posts-count] | |
function customprefix_total_number_published_posts($atts) { | |
return wp_count_posts('post')->publish; | |
} | |
add_shortcode('published-posts-count', 'customprefix_total_number_published_posts'); |
Below is the code to display the total number of published pages using a shortcode.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Display the total number of published pages using the shortcode [published-pages-count] | |
function customprefix_total_number_published_pages($atts) { | |
return wp_count_posts('page')->publish; | |
} | |
add_shortcode('published-pages-count', 'customprefix_total_number_published_pages'); |