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

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

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

replace current_page_item class in menu

Add this line at top of your display element function: add_filter(‘nav_menu_css_class’, ‘add_active_class_to_nav_menu’); Add this line at bottom of your display element function: remove_filter(‘nav_menu_css_class’, ‘add_active_class_to_nav_menu’); Add this function somewhere in your themes functions.php: function add_active_class_to_nav_menu($classes) { if (in_array(‘current-menu-item’, $classes, true) || in_array(‘current_page_item’, $classes, true)) { $classes = array_diff($classes, array(‘current-menu-item’, ‘current_page_item’, ‘active’)); $classes[] = ‘active’; } return … Read more

Customizing the a tag with Semantic UI

You are definitely on the right track, but wp_nav_menu will output a menu with a lot of containers and classnames; to keep it semantic in the terms of Semantic UI, you’ll be in good hands if you build the structure yourself. Get the name of the registered menu in the menu manager. Check register_nav_menu in … Read more

wp_nav_menu() not working on Custom Search Page

I know this is an old thread but the problem still exists. I think this is a bug. Default queries such as nav should not be affected in making custom search page. Anyways, this is how I fixed it: function fix_nav_menu_in_search($query) { if (is_search()) { $query->set(‘post_type’, [‘your_cpt’, ‘nav_menu_item’]); } return $query; } add_filter(‘pre_get_posts’, ‘fix_nav_menu_in_search’);

Remove/Disable “Automatically add new top-level pages to this menu”

Since there is no filter to remove this option, your best best to to stick to using CSS by putting the following in your child theme’s functions.php: add_action( ‘admin_head’, ‘wpse_225635_menu_css’ ); function wpse_225635_menu_css() { global $pagenow; if ( $pagenow == ‘nav-menus.php’ ) { ?> <style type=”text/css”> .auto-add-pages { display: none; } </style> <?php } }

Getting URL value from menu item by ID

Guessing the only way you get it without loop through the menu, is getting the post meta directly. Navigation menus are saved as custom post type into wp_posts, so you can get it with get_posts or get_post_meta. If it’s a custom link menu item, the code below should do it. Where $menu_id is you menu … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)