One Click Import demo plugin: Setting up the front page for each demo import name

Question

I installed One Click Import Demo plugin, I am trying to setting up the front page for each demo import name.i
For example, if I import “DEMO IMPORT 1,” then the front page will be “Home 1,”
when I import “DEMO IMPORT 2,” then the front page will be “Home 2.”

This is my code:

function ocdi_after_import_setup() {
    echo "This will be displayed on all after imports!";

    if ( 'DEMO IMPORT 1' === $selected_import['import_file_name'] ) {
    // Assign front page and posts page (blog page).
    $front_page_id = get_page_by_title( 'HOME 1' );
    $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 );   
    }
    elseif ( 'DEMO IMPORT 2' === $selected_import['import_file_name'] ) {
    // Assign front page and posts page (blog page).
    $front_page_id = get_page_by_title( 'HOME 2' );
    $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' );

Unfortunately, the code doesn’t work.

Any can guide me how to achieve this, please?

0
, , ryana milisku 1 year 0 Answers 74 views 0

Leave an answer