Created
May 30, 2017 08:06
-
-
Save fahidjavid/70e82b591d345ba4fbbee28bcc8a02d0 to your computer and use it in GitHub Desktop.
Set up the blog and front page plus menu locations after 'One Click Demo Import'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| if ( ! function_exists( 'prefix_after_import' ) ) { | |
| /** | |
| * Set up the news and front page plus menu locations | |
| * @param $selected_import | |
| */ | |
| function prefix_after_import( $selected_import ) { | |
| if ( 'Demo Import' === $selected_import['import_file_name'] ) { | |
| //Set Topbar & Header Menu | |
| $top_menu = get_term_by( 'name', 'Topbar Menu', 'nav_menu' ); | |
| $header_menu = get_term_by( 'name', 'Header Menu', 'nav_menu' ); | |
| set_theme_mod( 'nav_menu_locations', array( | |
| 'topbar-menu' => $top_menu->term_id, | |
| 'header-menu' => $header_menu->term_id, | |
| ) | |
| ); | |
| //Set Front page | |
| $page = get_page_by_title( 'Home' ); | |
| $blog_page_id = get_page_by_title( 'News' ); | |
| if ( isset( $page->ID ) ) { | |
| update_option( 'page_on_front', $page->ID ); | |
| update_option( 'show_on_front', 'page' ); | |
| update_option( 'page_for_posts', $blog_page_id->ID ); | |
| } | |
| } | |
| } | |
| add_action( 'pt-ocdi/after_import', 'prefix_after_import' ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment