I recently started an article directory using wordpress, and theme by dimox and plugin and plugin by artilcesss dot com.

On homepage it shows number registered authors and and published posts.

It is using %2$s for registered authors and %1$s for number of published articles in main index template.

I have so many unpublished articles too, so my question is that is there any way to show the number of unpublished articles (only counts) on the homepage?


thanks for the answers, it is useful for users like me, I am not expert in this, here is the code.

<p><?php global $numposts, $users; printf(__('We have <strong>%2$s</strong> registered authors and <strong>%1$s</strong> published articles till the date.', 'article-directory'), $numposts, $users); ?></p>

And this will show the output:

We have 24 registered authors and 43 published articles till the date.

(24 and 43 numbers are current statistics)


I think you are searching for this: http://codex.wordpress.org/Function_Reference/wp_count_posts

$count_posts = wp_count_posts();

$draft_posts = $count_posts->draft;

Rob's answer will get you the number. If you want to display it on the dashboard along with the other entries in the Right Now widget, you can use the right_now_content_table_end hook.

This snippet should add the current drafts count to your dashboard:

add_action( 'right_now_content_table_end', 'show_count_unpublished_posts' );

function show_count_recipes() {
    $count_posts = wp_count_posts();
    $draft_posts = $count_posts->draft;
    $num = '<a href="edit.php?post_status=draft&post_type=post">'.number_format_i18n( $draft_posts ).'</a>';
    $text = '<a href="edit.php?post_status=draft&post_type=post">'._n( 'Draft', 'Drafts', $draft_posts ).'</a>';
    echo "<tr>\n\t".'<td class="first b b-drafts">' . $num . '</td>';
    echo '<td class="t drafts">' . $text . '</td></tr>';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.