最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

posts - how can sort my column

programmeradmin3浏览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);

.

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/best-ceremonial-wedding-hall

Share Improve this question edited Nov 17, 2020 at 12:13 Mohammad Kamali asked Nov 15, 2020 at 8:25 Mohammad KamaliMohammad Kamali 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 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/manual/en/array.sorting.php

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论