1

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/… – adrian7 Jan 6 '13 at 13:31
  • adrian7, how can I show this metabox by default? – Stanislau Ladutska Jan 6 '13 at 13:36
  • I will post an answer when I find out. – adrian7 Jan 6 '13 at 13:42
1

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;
}
| improve this answer | |
0

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

| improve this answer | |
  • 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. – Stanislau Ladutska Jan 6 '13 at 13:23
  • 1
    @nackle your answer is not related to the question. – adrian7 Jan 6 '13 at 13:34
  • 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. – AndyWarren Apr 6 '13 at 15:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.