Nunivo,
What exactly are you trying to accomplish? Display the total amount of published posts?
@schulte
I am busy with job site that counts the active jobs and resumes. I also want something that counts the number of post (articles).
The theme that i use supports short codes (on the frontpage), for the above the theme developer made a short code. But a counter for post is behind their support (that’s understandable).
A fuction code that generates this short code, would solve my problem.
Thank you.
Nunivo,
Place the following at the end of your themes functions.php file and then add something like Number of Posts: [post_count] on your post or page to display the number of published posts.
function my_post_count() {
$count_posts = wp_count_posts();
$published_posts = $count_posts->publish;
return $published_posts;
}
add_shortcode('post_count', 'my_post_count');
add_filter('my_post_count', 'do_shortcode');
/* End Shortcode Post Count [post_count] */
lifted from from Digital Raindrops: https://wordpress.org/support/topic/inserting-a-variables-value-into-a-post
@schulte
Many thanks a friend of my helped me with adjusting the code, this is code that he gave me:
function my_post_count() {
$count_posts = wp_count_posts();
$published_posts = $count_posts->publish;
return $published_posts;
}
add_shortcode(‘my_post_count’, ‘my_post_count’);
Thanks for the help.