Last active
May 25, 2017 20:21
-
-
Save jpmarchand/e510527894bcc2f83d8b to your computer and use it in GitHub Desktop.
Display total number of posts using a shortcode. Source: https://codex.wordpress.org/Function_Reference/wp_count_posts
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'); |
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'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment