Title: [Plugin: WordPress Popular Posts] using the jQuery load() method
Last modified: August 20, 2016

---

# [Plugin: WordPress Popular Posts] using the jQuery load() method

 *  Resolved [carlodurso](https://wordpress.org/support/users/carlodurso/)
 * (@carlodurso)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/plugin-wordpress-popular-posts-using-the-jquery-load-method/)
 * Hi Hector,
    I’m actually using the jQuery load method to open posts on the main
   page.
 * With this scenario looks like that the page views number doesn’t update unless
   I open the post in single.php, in other words after I open the post as normal
   the page view number gets updated using the load() method.
 * Do you have any suggestions?
 * [http://wordpress.org/extend/plugins/wordpress-popular-posts/](http://wordpress.org/extend/plugins/wordpress-popular-posts/)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [Hector Cabrera](https://wordpress.org/support/users/hcabrera/)
 * (@hcabrera)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/plugin-wordpress-popular-posts-using-the-jquery-load-method/#post-3105236)
 * Hi carlodurso,
 * I’ve been thinking of a possible solution for this. See, when the page loads,
   my plugin uses ajax too to send the update to the database. In your case, you
   could try adding something like this to your script:
 *     ```
       <?php
       $nonce = wp_create_nonce('wpp-token');
       $id = 'YOUR-POST-ID-HERE';
       ?>
   
       jQuery.post('<?php echo admin_url('admin-ajax.php'); ?>', {action: 'wpp_update', token: '<?php echo $nonce; ?>', id: <?php echo $id; ?>}, function(data){/*alert(data);*/});
       ```
   
 * I haven’t tested this code, so let me know what happens.
 *  Thread Starter [carlodurso](https://wordpress.org/support/users/carlodurso/)
 * (@carlodurso)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/plugin-wordpress-popular-posts-using-the-jquery-load-method/#post-3105246)
 * Hi Hector,
 * It works great, as expected. Thanks a lot.
 * The only issue I have found is that it doesn’t work when I’m logged in either
   as admin or normal user. It’s not an issue for me but I thought it could be valuable
   for you.
 * Finally, does it matter if I generate the $nonce outside functions.php? Right
   now I’m generating a custom tag in the footer thus I can copy it via jQuery.
 * Thanks again for your help.
 *  Plugin Author [Hector Cabrera](https://wordpress.org/support/users/hcabrera/)
 * (@hcabrera)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/plugin-wordpress-popular-posts-using-the-jquery-load-method/#post-3105257)
 * Glad to know that, Carlo.
 * As long as a valid nonce is generated it shouldn’t matter.
 * About WPP not counting visits when logged in:
 * > **WordPress Popular Posts is not counting my own visits, why?**
   >  WordPress 
   > Popular Posts won’t count views generated by logged in users. If your blog 
   > requires readers to be logged in to access its contents, [this tutorial](http://wordpress.org/support/topic/398760)
   > is for you.
 *  Thread Starter [carlodurso](https://wordpress.org/support/users/carlodurso/)
 * (@carlodurso)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/plugin-wordpress-popular-posts-using-the-jquery-load-method/#post-3105260)
 * Thanks for the info.
 * Keep up your good work.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘[Plugin: WordPress Popular Posts] using the jQuery load() method’ is 
closed to new replies.

 * ![](https://ps.w.org/wordpress-popular-posts/assets/icon-256x256.png?rev=1232659)
 * [WP Popular Posts](https://wordpress.org/plugins/wordpress-popular-posts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wordpress-popular-posts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wordpress-popular-posts/)
 * [Active Topics](https://wordpress.org/support/plugin/wordpress-popular-posts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wordpress-popular-posts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wordpress-popular-posts/reviews/)

## Tags

 * [ajax](https://wordpress.org/support/topic-tag/ajax/)
 * [jquery](https://wordpress.org/support/topic-tag/jquery/)
 * [load](https://wordpress.org/support/topic-tag/load/)

 * 4 replies
 * 2 participants
 * Last reply from: [carlodurso](https://wordpress.org/support/users/carlodurso/)
 * Last activity: [13 years, 7 months ago](https://wordpress.org/support/topic/plugin-wordpress-popular-posts-using-the-jquery-load-method/#post-3105260)
 * Status: resolved