簡體   English   中英

在管理區域重組WordPress框

[英]Reorganization WordPress boxes in admin area

實際上,我在這里有兩個問題。

1:如何為用戶隱藏WordPress區域中的某些框(例如,類別框或評論框)?

2:如何按ID對類別框中的類別進行排序(默認情況下,它按名稱排序)。 例如,我想看看

the next order: 1, 2, 3...
but not 10, 1, 11

這里

對於問題1,
在活動主題的functions.php文件中添加以下代碼

function my_remove_meta_boxes() {
    if ( ! current_user_can( 'manage_options' ) ) {
        /**
         * arg-1 : id of the metabox, arg-2: page or posttype, arg-3: screen where the boxes displaying
         */
        remove_meta_box( 'tagsdiv-stages', 'post', 'side' ); // as per my page https://www.screencast.com/t/VCnvf61M7ydS
        remove_meta_box( 'commentsdiv', 'post', 'normal' );
    }
}
add_action( 'admin_menu', 'my_remove_meta_boxes' );

您可以參考: https : //codex.wordpress.org/Function_Reference/remove_meta_box

對於問題2,
請嘗試以下代碼。

function sort_get_terms_args( $args, $taxonomies ) {
    global $pagenow;
    if( !is_admin() || ('post.php' != $pagenow && 'post-new.php' != $pagenow) ) 
        return $args;

    $args['orderby'] = 'term_id';
    $args['order'] = 'ASC';

    return $args;
}
add_filter( 'get_terms_args', 'sort_get_terms_args', 10, 2 );

希望這對您有所幫助!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM