Skip to content

Instantly share code, notes, and snippets.

@dartiss
Created November 15, 2017 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dartiss/ed919c82a01b80f31b0ad7bfd11c3192 to your computer and use it in GitHub Desktop.
Save dartiss/ed919c82a01b80f31b0ad7bfd11c3192 to your computer and use it in GitHub Desktop.
Displays Number of Published WordPress Posts
<?php
function post_count_sc( $paras = '', $content = '' ) {
return wp_count_posts() -&gt; publish;
}
add_shortcode( 'post_count', 'post_count_sc' );
?>
@dartiss
Copy link
Author

dartiss commented Nov 15, 2017

Copy the code below into your theme's functions.php file and then place the shortcode [post_count] wherever you wish the count of posts to appear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment