0

How can I add order?

add_filter('manage_articles_posts_columns', 
function ( $columns ) 
{
    if( is_array( $columns ) && ! isset( $columns['post_views'] ) )
        $columns['post_views'] = __( 'views' );     
     if(current_user_can('administrator'))
    return $columns;
},  );

add_action( 'manage_articles_posts_custom_column', 
function ( $column_name, $post_id ) 
{
    if ( $column_name == 'post_views') {
        $post_view_count = get_post_meta($post_id, 'views', true);
        $count = $post_view_count ? $post_view_count : 0;
        if(current_user_can('administrator'))
            echo $count;
    }
 
}, 10, 2);

. https://www.talarkadeh.com/best-ceremonial-wedding-hall

1 Answer 1

0

Your columns are in an array. PHP has a few options you can use depending on how you want to sort the array (low to high, high to low, etc.). Here is the documentation for that. https://www.php.net/manual/en/array.sorting.php

1
  • I want to use the default WordPress order ... Nov 16, 2020 at 6:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.