• Resolved quangtuyen

    (@quangtuyen)


    Hello,

    In my theme I use the ocdi/after_import hook to specify the imported menus for the theme menu locations, but when I’m done importing the main menu is not displayed even though the data has been imported.

    function royalcar_after_import_setup() {
    	$header = get_term_by( 'slug', 'Primary', 'nav_menu' );
    
    	set_theme_mod(
    		'nav_menu_locations',
    		[
    			'menu-1' => $header->term_id,
    		]
    	);
    
    	$front_page = get_page_by_title( 'Home' );
    
    	update_option( 'show_on_front', 'page' );
    	update_option( 'page_on_front', $front_page->ID );
    
    	update_option( 'permalink_structure', '/%postname%/' );
    }
    
    add_action( 'ocdi/after_import', 'royalcar_after_import_setup' );

    View post on imgur.com

    Thank you in advance!

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

    (@capuderg)

    Hi @quangtuyen,

    is the “menu-1” the correct menu location in your theme?

    Is the front page being set successfully? I can see that custom code is also executed in the same hook, so if the front page is being set OK, that means that the hook did fire and the only issue is with the menu location ID.

    Take care!

    Thread Starter quangtuyen

    (@quangtuyen)

    Hi @capuderg,

    I found the problem in my theme, in the function get_term_by( ‘name’, ‘Primary’, ‘nav_menu’ );
    I am declaring the wrong name of the menu,

    Thank you very much!

    Plugin Author Gregor Capuder

    (@capuderg)

    Hey @quangtuyen,

    thanks for sharing with us ??

    Have a nice day!

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