WordPress.org

Ready to get started?Download WordPress

Forums

WordPress.com Stats
Solution for "#id (loading title)" coming back from stats_get_csv() function (3 posts)

  1. felthos
    Member
    Posted 3 years ago #

    Although I've seen folks say that their problem with Stats not displaying the 'top posts' correctly has been resolved by virtue of WordPress.com fixing the issue with Stats, I've still continued to see my top posts look like "#id (loading title)".

    I use Ben Gillbanks' code to pull stats back:

    if (function_exists('stats_get_csv')) {
        $top_posts = stats_get_csv ('postviews', 'days=30&limit=10');
        if (count($top_posts) > 0) {
          echo '<ul>';
          foreach ($top_posts as $p) {
            if ($p['post_id'] > 0) {
              ?>
              <li><a href="<?php echo $p['post_permalink']; ?>"><?php echo $p['post_title']; ?></a></li>
              <?php
            }
          }
          echo '</ul>';
        }
      }

    Now since I knew Stats were still being reported to and pulled back from the WordPress.com stats servers because I could see the data in my WordPress dashboard, I knew there had to be another way around this. stats_get_csv() was still pulling back the right post-id data because the weird "#id (loading title)" still showed the right ids (based on extrapolating from prior data), so I figured it was time to just let *my* WP install figure out the permalink and title, instead of stats. Slight mod of the code seems to do the trick:

    if (function_exists('stats_get_csv')) {
        $top_posts = stats_get_csv ('postviews', 'days=30&limit=10');
        if (count($top_posts) > 0) {
          echo '<ul>';
          foreach ($top_posts as $p) {
            if ($p['post_id'] > 0) {
              ?>
              <li><a href="<?php echo get_permalink($p['post_id']) ?>"><?php echo get_the_title($p['post_id']) ?></a></li>
              <?php
            }
          }
          echo '</ul>';
        }
      }

    http://wordpress.org/extend/plugins/stats/

  2. aparentdesign
    Member
    Posted 3 years ago #

    This could be very helpful, thanks. I was testing in a sandbox without full access to stats, and thought the error was due to that. However, now that it's live, I'm still seeing this loading title bs.

    I'm using a version of the script that filters out the home page results, and can be used in a sidebar widget. Surprised this isn't part of the plugin package!

  3. aparentdesign
    Member
    Posted 3 years ago #

    Works excellently. Thanks again.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic