title: WordPress notification if new post published
body: <p>I use WordPress and I want to alert users if new post with post_type = job_post was published. Also I want to show amount of new post.</p>
  <p>So I add to function.php</p>
  <pre><code>global $new_job_count = 0;
  
  function newJobAdded($ID, $post ) {
     $new_job_count = $new_job_count + 1;   
  }
  add_action( 'publish_job_post', 'newJobAdded', 10, 2 );
  
  function mytheme_new_job_count(){
        $new_job_count = 0;
  }
  </code></pre>
  <p>And I want to show new jobs message to users in main menu</p>
  <pre><code>&lt;li class=&quot;new_job_count_class&quot;&gt;&lt;a href=&quot;/newjobs&quot;&gt;New jobs count &lt;?php echo $new_job_count ?&gt;&lt;/a&gt;&lt;/li&gt;
  </code></pre>
  <p>Also I want to set $new_job_count to 0 if user click on New jobs count message</p>
  <pre><code>(function ($) {
    $(&quot;.new_job_count_class&quot;).on(&quot;click&quot;, function () {
       alert('click');
       $.ajax({
              url: '&lt;?php echo admin_url('admin-ajax.php');?&gt;', 
              type: 'POST',
              data:{ 
                action: 'mytheme_new_job_count' 
              },
              // success: function( data ){
              //     alert(&quot;success&quot;);
              //     location.reload();
              // }
           });
  
    });
  }(jQuery));
  </code></pre>
  <p>I'm having a lot of problem with this and I have hard time finding errors, but I didn't find anything helpful in my search so far.</p>
  <p>Thanks in advance.</p>