I'm creating custom wordpress theme. How can I enable "Description" metabox for menu items (on nav-menu page) by default programmatically?
-
"WordPress already comes with the option to add a description to each menu item, but it is hidden by default." See: kriesi.at/archives/…– adrian7Jan 6, 2013 at 13:31
-
adrian7, how can I show this metabox by default?– Stanislau LadutskaJan 6, 2013 at 13:36
-
I will post an answer when I find out.– adrian7Jan 6, 2013 at 13:42
2 Answers
Remove the description
from the user meta value 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;
}
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
-
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. Jan 6, 2013 at 13:23
-
1
-
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. Apr 6, 2013 at 15:36