• I’m not really sure what happened, but suddenly the plugin stopped tracking. I thought maybe I needed to clear the data so I did that to start fresh again. However, nothing is tracking whatsoever.

    The blog does not require the user to be logged in, and the wp_head() method is being called in the header.

    Any help is much appreciated

    (Here’s a link to the blog in question: https://www.bettyfordinstitute.org/publications/index.php)

Viewing 15 replies - 1 through 15 (of 15 total)
  • Thread Starter dzedward

    (@dzedward)

    Ugh, take the ending ‘)’ out of the link..

    Hi there,

    Just checked your site and for some reason, the script that my plugin uses to update to the tables is not being printed onto your theme’s header. Honestly, I don’t have a clue about this.

    Any recent changes/modifications on your blog? New plugins or something?

    Thread Starter dzedward

    (@dzedward)

    Well this morning I updated this plugin, along with 2 others (if I remember correctly: Yet another related posts, Facebook Like)..

    Thats the only change in a few weeks.. Everything was fine and dandy before. I tried deactivating/reactivating – removing completely (including db tables)/re-installing – even going back one version.. Nothing seems to help

    If you already tried installing a previous version of my plugin and the problem still persists then it must be something else.

    Try disabling all your plugins, re-enable WPP alone and check if it is able or not to communicate with your database.

    Thread Starter dzedward

    (@dzedward)

    After all plugins disabled, including Akismet, the problem still persists. What’s a good way for me to troubleshoot, ie, connection errors and so forth?

    “the script that my plugin uses to update to the tables is not being printed onto your theme’s header”

    So, it’s not including a required script? Which one, and what should the head for your plugin look like when on a page?

    Here’s a sample code of what you should see on your HTML when browsing a post or a page:

    <!-- WordPress Popular Posts v2.1.4 -->
    <script type="text/javascript" charset="utf-8">
        /* <![CDATA[ */
    	jQuery.post('https://www.yoursite.com/wp-admin/admin-ajax.php', {action: 'wpp_update', token: 'f2860a2095', id: 1});
        /* ]]> */
    </script>
    <!-- End WordPress Popular Posts v2.1.4 -->
    
    <!-- WordPress Popular Posts v2.1.4 -->
    <link rel="stylesheet" href="https://www.yoursite.com/wp-content/plugins/wordpress-popular-posts/style/wpp.css" type="text/css" media="screen" />
    <!-- End WordPress Popular Posts v2.1.4 -->

    You’re missing the first block of code (the jQuery one), which is vital since it updates to your database via AJAX whenever a visitor enters a post/page (this block won’t be printed for users that are logged into your wp-admin, such as yourself). I checked your site and this piece of code wasn’t printed for me.

    Thread Starter dzedward

    (@dzedward)

    Okay, so where do I need to look to debug this? Is there anything you know of that would prevent it from printing?

    Around line 460 in wordpress-popular-posts.php, change this:

    // prints ajax script to theme's header
    function wpp_print_ajax() {
        // let's add jQuery
        wp_print_scripts('jquery');
    
        // create security token
        $nonce = wp_create_nonce('wpp-token');
    
        // get current post's ID
        global $wp_query;
        wp_reset_query();
    
        // if we're on a page or post, load the script
        if ( (is_single() || is_page()) && !is_user_logged_in() ) {
            $id = $wp_query->post->ID;
        ?>
    <!-- WordPress Popular Posts v<?php echo $this->version; ?> -->
    <script type="text/javascript" charset="utf-8">
        /* <![CDATA[ */
    	jQuery.post('<?php echo admin_url('admin-ajax.php'); ?>', {action: 'wpp_update', token: '<?php echo $nonce; ?>', id: <?php echo $id; ?>});
        /* ]]> */
    </script>
    <!-- End WordPress Popular Posts v<?php echo $this->version; ?> -->
    	<?php
        }
    }

    … into this:

    // prints ajax script to theme's header
    function wpp_print_ajax() {
        // let's add jQuery
        wp_print_scripts('jquery');
    
        // create security token
        $nonce = wp_create_nonce('wpp-token');
    
        // get current post's ID
        global $wp_query;
        wp_reset_query();
    
        // if we're on a page or post, load the script
    
            $id = $wp_query->post->ID;
        ?>
    <!-- WordPress Popular Posts v<?php echo $this->version; ?> -->
    <script type="text/javascript" charset="utf-8">
        /* <![CDATA[ */
    	jQuery.post('<?php echo admin_url('admin-ajax.php'); ?>', {action: 'wpp_update', token: '<?php echo $nonce; ?>', id: <?php echo $id; ?>});
        /* ]]> */
    </script>
    <!-- End WordPress Popular Posts v<?php echo $this->version; ?> -->
    	<?php
    
    }

    That would force WPP to print the script regardless on which area of your blog the visitor is. This way, we could tell if the function that echoes the jQuery script is being called at all or not.

    Thread Starter dzedward

    (@dzedward)

    Hey Ikki24, thanks for this. Was just coming back to report that I changed this line:
    if ( (is_single() || is_page()) && !is_user_logged_in() ) {

    Into this:
    if ( !is_user_logged_in() ) {

    Now it works! Thanks a lot for the help and very fast responses. Just for your information, wordpress’s core lives in a different location than the actual posts on the site.. Even though wp-load.php is called at the beginning of the page, the plugin doesn’t seem to recognize where it’s at.. Anyway, thanks again

    The (is_single() || is_page()) part tells WPP not to print this code unless we’re seeing a post or a page. This block of code should not be printed anywhere else, otherwise your homepage could become your most popular page as it would be the one that gets the most views of them all!

    I’m also running WordPress on a different location (see cabrerahector.com for an example) and it works just fine, so I’m still worried about your issue.

    BTW, why is wp-load.php being called on a page?

    Just an FYI, I had this same experience. It seemed to occur after changing the settings. Initially, the settings were set to the previous 30 days, with comment count displayed and based on avg visits per day. It was changed to All-time with no count displayed. I also deselected pages from being displayed, but cannot recall if it was before the initial success or after I changed it to the All-Time settings.

    On the initial settings it pulled data and now pulls nothing. It is also missing that top part of the javascript code.

    I’ve just changed the code to what you listed above and the code snippet is now there. As I have this set to a widget that displays only on the blog page, I can’t think of any issue to changing from the adjusted code, but let me know if I am missing anything.

    OK, here’s an update. It’s been about a day with the adjusted code in place and still no data is displaying. Any ideas?

    Does this plugin work for news aggregators, searching in excerpts only? I have only excerpts on my site https://cheshmandaz.org and my titles are linking to the syndicated sources. No full text. What I am after is to see which titles are getting the most hits. Does this plugin make sense for this purpose? I have already installed it to try but after a few hours it still says “Sorry, no data yet.” I’d really appreciate any clarification. Thanks

    Dear Ikki, please have a look at my question a while ago. Just in case this plugin would work for rss feed sites (like mine, cheshmandaz.org), could you do that for me for a small donation? Agsin, I have only feeds (excerpts and no full text posts) and want a plugin to tell users which titles were clicked most (although they link NOT to me but to their original sites). I really don’t understand all these terms like php and css and <>..!

    Further update. I changed condition for display to Total Views for posts over All Time and the content populated quickly. It seems the Avg Visits per Day is not an option one would want to use for posts over All Time (still no data after 4 days).

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘[Plugin: WordPress Popular Posts] Sorry. No data so far. and Database Tables not updating’ is closed to new replies.