WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to display notification bar on header in my Wordpress theme when user submit certain number of post. I want to notify my author once they are submit amount of post. e.g.

if (authorpost === 50){

// congratulations! you have submitted total 50 posts bla bla.

} else if (authorpost === 100) {

// congratulations! you have submitted total 100 posts bla bla.

} else { // nothing will display }

I want this into header.php and will place my div right after tag. Also I want to display only when they submit certain number of post as I mention above as soon as they cross that number it won't display anything.

share|improve this question
Excuse me! I am trying to do in my wordpress template. – pixelngrain Jun 5 '12 at 17:39
up vote 4 down vote accepted

A simple way to achieve this would be to do something like the following;

    $user_id = get_current_user_id();
    $post_count = count_user_posts($user_id);

    if ($post_count >= 50 && $post_count < 100) {
         // Congratulations you have submitted 50 posts!
    } elseif ($post_count >= 100) {
        // etc etc...
    } else {
        // do something else, or nothing.

You can place this within your header.php file, or for that matter in any template file should you choose to display this information elsewhere as this can run from out-side of your post loop.

WordPress API resources:

  • get_current_user_id LINK
  • count_user_posts LINK
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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