• allyson

    (@allysonamboni)


    Hi,

    Good day. I’m using a plugin called Event Espresso 4 Decaf (https://ww.wp.xz.cn/plugins/event-espresso-decaf) and the post views is not shown in the events table by default.

    I’ve successfully added the post views column by including this in my theme’s functions.php, but the sorting is not working.

    
    add_filter( 'FHEE_manage_toplevel_page_espresso_events_columns', 'theme_events_table_head', 10, 2 );
    function theme_events_table_head( $columns ) {
        if ( is_plugin_active( 'post-views-counter/post-views-counter.php' )
            && in_array( 'espresso_events', Post_Views_Counter()->options['general']['post_types_count'] ) ) {
            $columns['post_views'] = '<span class="dash-icon dashicons dashicons-chart-bar" title="Post Views"><span class="screen-reader-text">Post Views</span></span>';
            return $columns;
        }
        return $columns;
    }
    add_filter( 'FHEE_manage_toplevel_page_espresso_events_sortable_columns', 'theme_events_sortable_table_head', 10, 2 );
    function theme_events_sortable_table_head( $columns ) {
        if ( is_plugin_active( 'post-views-counter/post-views-counter.php' )
            && in_array( 'espresso_events', Post_Views_Counter()->options['general']['post_types_count'] ) ) {
            $columns['post_views'] = 'post_views';
            return $columns;
        }
        return $columns;
    }
    
    add_action( 'AHEE__EE_Admin_List_Table__column_post_views__toplevel_page_espresso_events', 'theme_events_table_content', 10, 2 );
    function theme_events_table_content( $item ) {
        if ( is_plugin_active( 'post-views-counter/post-views-counter.php' )
            && in_array( 'espresso_events', Post_Views_Counter()->options['general']['post_types_count'] ) ) {
            if (!$item instanceof EE_Event) {
                return '';
            }
            echo pvc_get_post_views( $item->ID() );
        }
    }
    

The topic ‘Event Espresso 4 Decaf admin table sorting problem’ is closed to new replies.