如何以编程方式激活菜单项的“描述”元框?
-
-
" WordPress已经带有向每个菜单项添加描述的选项,但是默认情况下它是隐藏的."请参阅:http://www.kriesi.at/archives/improve-your-wordpress-navigation-menu-output"WordPress already comes with the option to add a description to each menu item, but it is hidden by default." See: http://www.kriesi.at/archives/improve-your-wordpress-navigation-menu-output
- 0
- 2013-01-06
- adrian7
-
adrian7,默认情况下如何显示此metabox?adrian7, how can I show this metabox by default?
- 0
- 2013-01-06
- Stanislau Ladutska
-
找到答案后,我会发布答案.I will post an answer when I find out.
- 0
- 2013-01-06
- adrian7
-
2 个回答
- 投票数
-
- 2013-01-06
从用户元值
description
中删除managenav-menuscolumnshidden
:add_filter( 'manage_nav-menus_columns', 'enable_nav_menu_description_by_default' ); function enable_nav_menu_description_by_default( $columns ) { $desc_key = 'managenav-menuscolumnshidden'; $hidden = get_user_option( $desc_key ); $user_id = wp_get_current_user()->ID; if ( ! $hidden ) { update_user_option( $user_id, $desc_key, array ( 0 => 'link-target', 1 => 'css-classes', 2 => 'xfn' ) ); } elseif ( FALSE !== ( $key = array_search( 'description', $hidden ) ) ) { unset( $hidden[ $key ] ); update_user_option( $user_id, $desc_key, $hidden ); } return $columns; }
Remove the
description
from the user meta valuemanagenav-menuscolumnshidden
:add_filter( 'manage_nav-menus_columns', 'enable_nav_menu_description_by_default' ); function enable_nav_menu_description_by_default( $columns ) { $desc_key = 'managenav-menuscolumnshidden'; $hidden = get_user_option( $desc_key ); $user_id = wp_get_current_user()->ID; if ( ! $hidden ) { update_user_option( $user_id, $desc_key, array ( 0 => 'link-target', 1 => 'css-classes', 2 => 'xfn' ) ); } elseif ( FALSE !== ( $key = array_search( 'description', $hidden ) ) ) { unset( $hidden[ $key ] ); update_user_option( $user_id, $desc_key, $hidden ); } return $columns; }
-
- 2013-01-06
如果您要输出菜单说明,这里是一个有用的教程,使用WordPress Walker Menu类来增强菜单 Wordpress Walker菜单教程
If you're looking to output the menu description here is a useful tutorial using WordPress Walker Menu class to enchance the menu Wordpress Walker Menu Tutorial
-
谢谢纳克尔的回答.但是我需要一点不同的东西.我需要在导航菜单屏幕上的管理面板中启用metabox.Thank you nackle for your answer. But I need a little different thing. I need to enable metabox in admin panel, on nav-menus screen.
- 0
- 2013-01-06
- Stanislau Ladutska
-
@nackle您的答案与问题无关.@nackle your answer is not related to the question.
- 1
- 2013-01-06
- adrian7
-
它可能与原始问题无关,但是在此处搜索"nav description"使该帖子成为第一个结果.哪一个反过来回答了我关于如何显示导航描述的问题.为此支持.It may not be related the the original question, but a search on here for "nav description" brought this post as the first result. Which in turned answered the question that I came here with on how to display nav descriptions. Upvote for that.
- 0
- 2013-04-06
- AndyWarren
我正在创建自定义的wordpress主题.如何默认以编程方式为菜单项(在导航菜单页面上)启用"描述"元框?