• Resolved joand

    (@joand)


    Hi @capuderg – I hope all is well! We (Divi child theme developers) are running into occasional issues. As per the documentation, we have set up a function in the child theme style sheet to set the Home page, which works great. But sometimes we have somebody who wants to change that (e.g. I just had someone who wants to create a “coming soon” page while the site is in development.) They change it in their WordPress settings, but then the funtion changes it back to the Home page that we set! We tell them to delete those lines from the functions.php to get around it – but I am wondering if there is another way to code it so that the “after import” functions would only run after the “Import Demo Data” button is pushed, rather than every time the site loads?

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

    (@capuderg)

    Hi,

    the after import action is triggered only when the demo import button is clicked (at the end of the demo import progress). So, if set correctly, it should not execute ever again, except if you import the demo again.

    Either the after import action is not coded properly or something else is causing this issue.

    Could you please show me, how you coded the after import action hook?

    Take care!

    Thread Starter joand

    (@joand)

    Okay, that’s good news! I must have it wrong (which means it can be fixed!) I actually think I see where I have gone wrong. This is what I have:

    /*Set Front Page from Reading Options*/
    $front_page = get_page_by_title( 'Home' );
    if(isset( $front_page ) && $front_page->ID) {
    update_option('show_on_front', 'page');
    update_option('page_on_front', $front_page->ID);
    }
    
    /*Assign menus*/
    
    function ocdi_after_import_setup() {
    	// Menus to assign after import.
    	$primary_menu   = get_term_by( 'name', 'Primary Menu', 'nav_menu' );
    	$secondary_menu = get_term_by( 'name', 'Secondary Menu', 'nav_menu' );
    	set_theme_mod( 'nav_menu_locations', array(
    		'primary-menu'   => $primary_menu->term_id,
    		'secondary-menu' => $secondary_menu->term_id,
    	));
    }
    add_action( 'pt-ocdi/after_import', 'ocdi_after_import_setup' );
    
    wp_delete_post(1);
    wp_delete_post(2);

    I should have everything inside of the function ocdi_after_import_setup – is that right?

    Plugin Author Gregor Capuder

    (@capuderg)

    Hi,

    yes, that is correct @joand ??

    That will solve your issue.

    Have a nice day!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘After Import Actions’ is closed to new replies.