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

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Hector Cabrera


    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:

    $nonce = wp_create_nonce('wpp-token');
    $id = 'YOUR-POST-ID-HERE';
    ?>'<?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.

    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


    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 is for you.

    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.