Change an li class name in a wordpress custom menu walker

Troubleshooting Enabling the WP_DEBUG constant in wp-config.php exposed the following errors: – Function Signatures If Strict Standards is enabled, you’ll see an error detailing incompatible method signatures. Though not absolutely necessary, I like to eliminate as many errors as possible. To correct this, the new Walker_Nav_Menu class’s start_el() and start_lvl() methods’ declarations need to match … Read more

multisite: global menu containing network site links?

[*] get_sites() will get a list of the sites in a Multisite network. You can then use switch_to_blog()[*], get_posts() / get_pages(), and restore_current_blog()[*] to get the pages from the various sites. I’d strongly recommend storing the results as a sitewide option using update_site_option() to lessen the load on your server. You could add a job … Read more

How do you manage large menu hierarchies in WP?

It’s an issue with WP core that hierarchies don’t display in Appearance > Menu > Product Categories tab. In that ticket you can find workarounds: https://core.trac.wordpress.org/ticket/18282 For me worked partially (displayed the hierarchy to the left) this plugin, discussed in the above ticket: https://core.trac.wordpress.org/attachment/ticket/18282/preserve-page-and-taxonomy-hierarchy.php you can download it at the bottom of the page and … Read more

Custom Menu url is Empty

Your menu type is: ‘menu-item-type’ => ‘Custom’, But if we look in wp_update_nav_menu_item: if ( ‘custom’ != $args[‘menu-item-type’] ) { custom != Custom, so your URL gets stripped

How to change menu URLs to hashes?

Here’s how I solved it so far. class themename_walker_nav_menu extends Walker_Nav_Menu { function start_el( &$output, $item, $depth, $args ) { $slug = get_post( $item->object_id )->post_name; $item->url = “#{$slug}”; return parent::start_el( $output, $item, $depth, $args ); } }

Sub Menu content is being duplicated

I was using the same page name for both. You can see in this snippet that I used “BCRM” and I didn’t realize it. add_submenu_page( __FILE__, ‘BCRM Customer Settings’, ‘Customer Settings’, ‘administrator’, ‘**BCRM**’, ‘bcrm_customer_settings_page’); add_submenu_page( __FILE__, ‘BCRM Form Settings’, ‘Form Settings’, ‘administrator’, ‘**BCRM**’, ‘bcrm_form_settings_page’); I changed them to BCRM_customers and BCRM_forms respectively and it is … Read more

View h2 content tags of a page in sub menu

Basically, you add a custom walker to wp_nav_menu. Whenever an item begins, you can check for the content of the page underlaying the navigation item. When a content is available, read the content into a new DOMDocument-Object and filter out all titles. With the titles, create sub-links to the current link beeing made in the … Read more