Support » Plugin: One Click Demo Import » Auto assign Front page displays

  • Resolved 6 Hour Creative

    (@6hourcreative)


    Hi,
    Thank you for great the plugin, it works perfectly with my themes.

    Do you know how to automatically assign Home and Blog in the Settings > Reading front page displays after the importer done?

    Thank you.

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

    (@capuderg)

    Hi,

    you can do that in the pt-ocdi/after_import action hook. The code that we use in our themes, to set the front page displays is:

    
    function ocdi_after_import_setup() {
    	// Assign menus to their locations.
    	$main_menu = get_term_by( 'name', 'Main Menu', 'nav_menu' );
    
    	set_theme_mod( 'nav_menu_locations', array(
    			'main-menu'   => $main_menu->term_id,
    		)
    	);
    
    	// Assign front page and blog page.
    	$front_page_id = get_page_by_title( 'Home' );
    	$blog_page_id  = get_page_by_title( 'Blog' );
    
    	update_option( 'show_on_front', 'page' );
    	update_option( 'page_on_front', $front_page_id->ID );
    	update_option( 'page_for_posts', $blog_page_id->ID );
    
    }
    add_action( 'pt-ocdi/after_import', 'ocdi_after_import_setup' );
    

    You can delete the first bit, which assigns the menus to the correct locations.

    Take care!

    PS: If you like our plugin, please rate it here https://wordpress.org/support/plugin/one-click-demo-import/reviews/, we would really appreciate it.

    Thread Starter 6 Hour Creative

    (@6hourcreative)

    Oh thank you @capuderg I actually need the auto assign menu location too. Once again thank you!

    By the way, you can add my question to FAQ section, in case someone needs it too 🙂

    Regards,
    Satrya

    Plugin Author Gregor Capuder

    (@capuderg)

    Hi Satrya,

    I was thinking about it as well (to add this to FAQ), so I’ll do that 🙂

    Have a nice day!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Auto assign Front page displays’ is closed to new replies.