Home Forums WoodMart support forum Override settings

Override settings

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #478461

    loucas
    Participant

    Hi guys, thanks for your theme!

    I’m working to override the nav walker to have an additional settings “Menu item background”
    nav item menu settings

    So far I’ve tried to override the walker method #1: add filter to child theme not successful

    
    // Register walker replacement
    add_filter( 'wp_edit_nav_menu_walker',   array( $this, 'custom_filter_walker' ) );
    

    I also tried method #2 to override the entire woodmart/functions.php into woodmart-child/functions/php and it throws an error that “Direct access not allowed”.

    Please advise.

    PS: Running currently perfectly fine on a MAMP with latest updates, activated theme, PHP 8.2 no issues at all.

    • This topic was modified 1 year, 10 months ago by loucas.
    • This topic was modified 1 year, 10 months ago by loucas.
    • This topic was modified 1 year, 10 months ago by loucas.
    • This topic was modified 1 year, 10 months ago by loucas.
    #478497

    Artem Temos
    Keymaster

    Hello,

    If you want to set a special walker class for the menu you can use the following code. Note that our support doesn’t cover any errors caused by additional customization

    class Custom_Walker extends Walker_Nav_Menu {
    }
    
    function set_custom_walker( $args ) {
    	$args['walker'] = new Custom_Walker();
    
    	return $args;
    }
    
    add_filter( 'wp_nav_menu_args', 'set_custom_walker' );

    Kind Regards

    #478509

    loucas
    Participant

    Thank you, useful info for the frontend view!

    However I also need a way for editing the menu item to have an additional option as shown above.

    Thank you!

    #478520

    loucas
    Participant

    I think I managed:

    
    function set_edit_walker( $walker ) {
    	$walker = 'NL_Walker_Nav_Menu_Edit';
        return $walker;
    }
    
    if (is_admin()) {
    	add_filter( 'wp_edit_nav_menu_walker', 'set_edit_walker', 99 );
    }
    

    Thanks again.

    #478541

    Artem Temos
    Keymaster

    Great, we are glad that you managed it. Feel free to contact us if you have any further questions.

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Override settings’ is closed to new replies.