• OK. Installed ‘WordPress.com Stats’ and ‘WordPress.com Stats Helper’. Then I was trying to use the wpcomstats_visits() to pull stats into the edit.php file (admin post list). I accomplished this by installing and modifying ‘Admin Word Count’. Here is what I did:

    //mostly original
    add_filter(‘manage_posts_columns’, ‘count_columns’);
    function count_columns($defaults) {
    $defaults[‘count’] = __(‘WC’);
    $defaults[‘stats’] = __(‘Hits’); //added this
    return $defaults;
    }

    //original code
    add_action(‘manage_posts_custom_column’, ‘count_custom_column’, 10, 2);
    function count_custom_column($column, $post_id)
    {
    global $post;
    if($column == ‘count’) {
    echo str_word_count(strip_tags($post->post_content), 0);
    }
    }

    //added this
    add_action(‘manage_posts_custom_column’, ‘stats_custom_column’, 10, 2);
    function stats_custom_column($column, $post_id)
    {
    global $post;
    if($column == ‘stats’) {
    wpcomstats_visits(‘ ‘,’ ‘ , get_the_ID() , 0);
    }
    }

    This worked GREAT! Well almost. The edit.php takes forever to load now. The only thing I could think would be to program a batch process to pull the data in the back end once a day. I can’t do that. Anyone want to write the plugin or have another suggestion?

  • The topic ‘Added post stats into edit.php, but there is a problem.’ is closed to new replies.