Search code examples
wordpressmenuthemesnavgenesis

Repositioning Genesis Nav not working - Issue with remove_action()


I'm new to Genesis (and stack overflow).

I used the following code to reposition my primary and secondary navs above my header, which worked, however it also left a copy of both navs below the header in it's original place. So basically duplicated my navs :(

// Reposition the primary navigation menu
remove_action( 'genesis_after_header', 'genesis_do_nav' );
add_action( 'genesis_header', 'genesis_do_nav', 12 );

// Reposition the secondary navigation menu
remove_action( 'genesis_after_header', 'genesis_do_subnav' );
add_action( 'genesis_before_header', 'genesis_do_subnav' );

Any ideas? The test site I'm playing around with is at: http://atelierblanc.pixelboutique.co.uk

Thanks


Solution

  • remove_action() must be called inside a function and cannot be called directly in your plugin or theme.

    you may try this :

    add_action( 'wp_head', 'remove_my_action' );
    function remove_my_action(){
        remove_action( 'genesis_after_header', 'genesis_do_nav' );
        remove_action( 'genesis_after_header', 'genesis_do_subnav' );
    }
    

    you can learn more here : https://codex.wordpress.org/Function_Reference/remove_action