How to making dynamic URLs for menus in WordPress?

If you have Custom Link URL exactly as written in your example, it should work as expected. “https://wordpress.stackexchange.com/” at the beginning already means “site root”, and it should work on single (first) click. Maybe you have some menu related plugin installed, or your theme changes menu URLs in some way. Or there is client side … Read more

Rename the label on a menu location which is already defined?

You are right there is no filter for this, you would have to hack the global instead, in this case $_wp_registered_nav_menus: add_action(‘after_setup_theme’, ‘custom_menu_location_label’); function custom_menu_location_label() { global $_wp_registered_nav_menus; $find = __(‘Header Menu’); $replace = __(‘Something Else’); foreach ($_wp_registered_nav_menus as $location => $description) { if ($find == $description) { $_wp_registered_nav_menus[$location] = $replace; } } }

Change menu based on page template via functions.php

The $args the filter is receiving includes the theme_location used when the menu was registered, so assuming your main location is primary, you can add the following to your if statement to target only that menu: if ( is_page_template( ‘page-template-custom.php’ ) && isset( $args[‘theme_location’] ) && ‘primary’ === $args[‘theme_location’] ) ) { … See: https://developer.wordpress.org/reference/hooks/wp_nav_menu_args/ … Read more

Trouble hiding menu on single page

This should do it: .page-id-17091 div.fixed-header-box { display: none; } I’d generally prefer setting the theme up to not generate the header for that page, though, rather than hiding it after the fact.

wp_trim_words strips dashicons

Your problem is that your filter is trimming all titles to 7 “words”. This includes blog posts, pages, menu item labels, revision names, and even product names, if you have products. You need to adjust your filter to be less aggressive and only target the titles that you need to truncate. For example, the following … Read more

Search if menu item has child in wp_get_nav_menu_items hook

If you want to use the wp_get_nav_menu_items hook, then try the function below which should be hooked after the exclude_menu_items function: // Example when NOT using a class: (you already defined the exclude_menu_items function) add_filter( ‘wp_get_nav_menu_items’, ‘exclude_menu_items’, 10, 3 ); add_filter( ‘wp_get_nav_menu_items’, ‘exclude_menu_items2’ ); function exclude_menu_items2( $items ) { if ( current_user_can( ‘administrator’ ) ) … Read more

Nav menus all outputting the same links

I have registered the following menus in my functions.php Note that register_nav_menus() which uses register_nav_menu() (note the singular “menu”) does not register or create a navigation menu; it only registers navigation menu locations which you can assign one or more (navigation) menus to, and for displaying the menus assigned to a specific location, you can … Read more