How do I give class to the dropdown sub-menu in the wp_nav_menu?

You can use Walker_Nav_Menu (WordPress Default class). Here is an example – In header.php file – <nav id=”header-menu”> <?php wp_nav_menu( array( ‘theme_location’ => ‘primary’, ‘walker’ => new Child_Wrap() ) ); ?> </nav> In my functions.php file – class Child_Wrap extends Walker_Nav_Menu { function start_lvl(&$output, $depth = 0, $args = array()) { $indent = str_repeat(“\t”, $depth); … Read more

wp_nav_menu() customized

In my basis theme I use a walker for a simplified output: <?php # -*- coding: utf-8 -*- /** * Create a nav menu with very basic markup. * */ class T5_Nav_Menu_Walker_Simple extends Walker_Nav_Menu { /** * Start the element output. * * @param string $output Passed by reference. Used to append additional content. * … Read more

Add column to pages table

Also an tutorial with an solution for page and post to add thumbnail in a column: http://wpengineer.com/1960/display-post-thumbnail-post-page-overview/ Change the content from thumbnail to your content and remove the hooks for post: // for posts // add_filter( ‘manage_posts_columns’, ‘fb_AddThumbColumn’ ); // add_action( ‘manage_posts_custom_column’, ‘fb_AddThumbValue’, 10, 2 ); // for pages add_filter( ‘manage_pages_columns’, ‘fb_AddThumbColumn’ ); add_action( ‘manage_pages_custom_column’, … Read more

How to add current, parent, and ancestor menu item IDs to body_class()?

From my comment earlier: Use the body_class() function in your header.php file or wherever your body tag is, e.g. <body <?php body_class(); ?>>. This will give you an output with a bunch of classes on the body that you can then use in your CSS. For example, <body class=”page page-id-114 page-parent page-template-default logged-in admin-bar”>. You … Read more

Custom metabox for menu administration page?

Just as a follow up for anybody looking to add their own meta boxes to the menu screen, you can do it by using ‘nav-menus’ for the post type: add_action( ‘admin_init’, ‘my_add_meta_box’ ); function my_add_meta_box() { add_meta_box( ‘custom-meta-box’, __(‘My meta box’), ‘my_nav_menu_item_link_meta_box’, ‘nav-menus’, ‘side’, ‘default’ ); } function my_nav_menu_item_link_meta_box() { ?> <div class=”custom-meta-box” id=”custom-meta-box”> Your … Read more

Adding attributes to link in wp_nav_menu using custom Walker function

You want to modify the start_el method as you did the start_lvl one. At its most basic it would mean altering this line: $item_output .= ‘<a’. $attributes .’>’; To look like this one: $item_output .= ‘<a class=”dropdown-toggle” data-toggle=”dropdown”‘. $attributes .’>’; It looks like you will need more complicated logic to avoid inserting that string in … Read more