• Resolved grumo64

    (@grumo64)


    Hi Jeremy,

    I was able to add your shortcode in admin column like that, It works but it’s very slow.

    Do you have a fix or a better way to do so?

    /**
    * Add a Views columns to insert jetpack postviews data into
    */
    function kb_add_views_column($cols)
    {
    return array_merge(
    array_slice($cols, 0, 2),
    array(
    'pageviews' => __('Vues <span class="dashicons dashicons-visibility"></span><style>.column-pageviews, .pageviews { width: 100px !important;text-align:center!important}</style>', 'textdomain')
    ),
    array_slice($cols, 2)
    );
    return $cols;
    }
    add_filter('manage_edit-post_columns', 'kb_add_views_column');
    //add_filter('manage_edit-event_columns', 'kb_add_views_column'); //for cpt

    // Grab and display the postviews data from Jetpack for each post
    function kb_add_views_colunm_data($colname)
    {

    // Make sure we're inserting into the correct column
    if ('pageviews' !== $colname)
    return false;

    echo '<strong>' . do_shortcode('[jp_post_view]') . '</strong>';
    }
    add_action('manage_posts_custom_column', 'kb_add_views_colunm_data');
    //add_action( 'manage_event_custom_column', 'kb_add_views_colunm_data' ); //for cpt

    /**
    * change the jp_post_views_cache_duration to 30 secondes
    */
    function kb_post_views_cache_duration()
    {
    return 30;
    }
    add_filter('jp_post_views_cache_duration', 'kb_post_views_cache_duration');
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

The topic ‘Admin column’ is closed to new replies.