• Resolved moxiecreek

    (@moxiecreek)


    How can I import and assign my primary and my secondary menu? Is it best to have the menus named something other than primary and secondary? I’m getting confused as to what to change in the example.

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Gregor Capuder

    (@capuderg)

    Hi @moxiecreek,

    you want to assign your menus to the predefined menu locations right?

    You can do it with this pt-ocdi/after_import action:

    
    function ocdi_after_import_setup() {
        // Assign menus to their locations.
        $primary   = get_term_by( 'name', 'Primary', 'nav_menu' );
        $secondary = get_term_by( 'name', 'Secondary', 'nav_menu' );
    
        set_theme_mod( 'nav_menu_locations', array(
                'primary'   => $primary->term_id,
                'secondary' => $secondary->term_id,
            )
        );
    }
    add_action( 'pt-ocdi/after_import', 'ocdi_after_import_setup' );
    

    In the example above I’ve used the names of your menus to be “Primary” and “Secondary”, so change that, if your menu names are different. Also in the second block of code you should change the “primary” and “secondary” menu locations, if you have them defined as something else.

    Let me know, if you need additional help, or if I misunderstood your question.

    Take care!

    Thread Starter moxiecreek

    (@moxiecreek)

    Hi @capuderg,

    Thanks for your quick response. I was able to get this to work finally! I actually renamed my menus to something other than “Primary” and “Secondary” and that helped to sort it all out.

    Plugin Author Gregor Capuder

    (@capuderg)

    Hi,

    no problem ??

    I’m glad you solved it!

    Have a nice day!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Importing Secondary Menu’ is closed to new replies.