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.

  • Excuse me! I am trying to do in my wordpress template. Commented Jun 5, 2012 at 17:39

1 Answer 1


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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