更改仪表板中特定插件的菜单顺序

时间:2021-09-25 作者:nooblag

的扩展this 以某种方式提问。

我的Wordpress仪表板菜单如下所示:

Array
(
    [2] => Array
        (
            [0] => Dashboard
            [1] => read
            [2] => index.php
            [3] => 
            [4] => menu-top menu-top-first menu-icon-dashboard
            [5] => menu-dashboard
            [6] => dashicons-dashboard
        )

    [4] => Array
        (
            [0] => 
            [1] => read
            [2] => separator1
            [3] => 
            [4] => wp-menu-separator
        )

    [10] => Array
        (
            [0] => Media
            [1] => upload_files
            [2] => upload.php
            [3] => 
            [4] => menu-top menu-icon-media
            [5] => menu-media
            [6] => dashicons-admin-media
        )

    [15] => Array
        (
            [0] => Links
            [1] => manage_links
            [2] => edit-tags.php?taxonomy=link_category
            [3] => 
            [4] => menu-top menu-icon-links
            [5] => menu-links
            [6] => dashicons-admin-links
        )

    [25] => Array
        (
            [0] => Comments <span class="awaiting-mod count-0"><span class="pending-count" aria-hidden="true">0</span><span class="comments-in-moderation-text screen-reader-text">0 Comments in moderation</span></span>
            [1] => edit_posts
            [2] => edit-comments.php
            [3] => 
            [4] => menu-top menu-icon-comments
            [5] => menu-comments
            [6] => dashicons-admin-comments
        )

    [5] => Array
        (
            [0] => Posts
            [1] => edit_posts
            [2] => edit.php
            [3] => 
            [4] => menu-top menu-icon-post open-if-no-js
            [5] => menu-posts
            [6] => dashicons-admin-post
        )

    [20] => Array
        (
            [0] => Pages
            [1] => edit_pages
            [2] => edit.php?post_type=page
            [3] => 
            [4] => menu-top menu-icon-page
            [5] => menu-pages
            [6] => dashicons-admin-page
        )

    [26] => Array
        (
            [0] => Templates
            [1] => edit_posts
            [2] => edit.php?post_type=elementor_library
            [3] => 
            [4] => menu-top menu-icon-elementor_library
            [5] => menu-posts-elementor_library
            [6] => dashicons-admin-page
        )

    [27] => Array
        (
            [0] => Donations
            [1] => edit_give_forms
            [2] => edit.php?post_type=give_forms
            [3] => 
            [4] => menu-top menu-icon-give_forms
            [5] => menu-posts-give_forms
            [6] => dashicons-give
        )

    [6] => Array
        (
            [0] => WP Links Page
            [1] => manage_options
            [2] => edit.php?post_type=wplp_link
            [3] => 
            [4] => menu-top menu-icon-wplp_link
            [5] => menu-posts-wplp_link
            [6] => dashicons-admin-links
        )

    [59] => Array
        (
            [0] => 
            [1] => read
            [2] => separator2
            [3] => 
            [4] => wp-menu-separator
        )

    [60] => Array
        (
            [0] => Appearance
            [1] => switch_themes
            [2] => themes.php
            [3] => 
            [4] => menu-top menu-icon-appearance
            [5] => menu-appearance
            [6] => dashicons-admin-appearance
        )

    [65] => Array
        (
            [0] => Plugins <span class="update-plugins count-4"><span class="plugin-count">4</span></span>
            [1] => activate_plugins
            [2] => plugins.php
            [3] => 
            [4] => menu-top menu-icon-plugins
            [5] => menu-plugins
            [6] => dashicons-admin-plugins
        )

    [70] => Array
        (
            [0] => Users
            [1] => list_users
            [2] => users.php
            [3] => 
            [4] => menu-top menu-icon-users
            [5] => menu-users
            [6] => dashicons-admin-users
        )

    [75] => Array
        (
            [0] => Tools
            [1] => edit_posts
            [2] => tools.php
            [3] => 
            [4] => menu-top menu-icon-tools
            [5] => menu-tools
            [6] => dashicons-admin-tools
        )

    [80] => Array
        (
            [0] => Settings
            [1] => manage_options
            [2] => options-general.php
            [3] => 
            [4] => menu-top menu-icon-settings
            [5] => menu-settings
            [6] => dashicons-admin-settings
        )

    [99] => Array
        (
            [0] => 
            [1] => read
            [2] => separator-last
            [3] => 
            [4] => wp-menu-separator
        )

    [30] => Array
        (
            [0] => Contact
            [1] => wpcf7_read_contact_forms
            [2] => wpcf7
            [3] => Contact Form 7
            [4] => menu-top toplevel_page_wpcf7
            [5] => toplevel_page_wpcf7
            [6] => dashicons-email
        )

    [100] => Array
        (
            [0] => Slider Revolution
            [1] => manage_options
            [2] => revslider
            [3] => Slider Revolution
            [4] => menu-top toplevel_page_revslider
            [5] => toplevel_page_revslider
            [6] => dashicons-update
        )
我可以在主题中输入什么代码functions.php 更改条目#6“;WP链接页面;始终低于“;“页码”;(即在20秒范围内,根据this advice)?

实际的

Actual

所需

Expected

1 个回复
最合适的回答,由SO网友:Sally CJ 整理而成

我可以看到;WP链接页面;是一种自定义帖子类型,因此如果它不是由您自己的代码注册的,例如,它是由插件注册的(使用register_post_type()), 然后您可以使用register_post_type_args filter 更改menu_position 类似这样的论点:

add_filter( \'register_post_type_args\', \'my_override_register_post_type_args\', 10, 2 );
function my_override_register_post_type_args( $args, $post_type ) {
    // Move "WP Links Page" to below the "Pages". You could also try using 21 instead.
    if ( \'wplp_link\' === $post_type ) {
        $args[\'menu_position\'] = 20;
    }

    return $args;
}

相关推荐

Dashboard menu missing

我失去了wp_users 和wp_usermeta wordpress安装中的表。我已经重新创建了它们并插入了一个新的管理员用户。特别是wpAA_users (我使用前缀wpAA_), 我现在有一个用户admin 具有ID=1, 在中时wpAA_usermeta, 对于user_id=1 我有wp_cabilities 设置为a:1:{s:13:\"administrator\";b:1;} 和wp_user_level 设置为10.现在,当我登录到该站点时,顶部工具栏左侧显示常规wordpress菜单,