• Resolved arzubrov

    (@arzubrov)


    Hello, I wanted to write a code so that, after importing, it automatically selects the shop page, I did not succeed, can you help how what needs to be changed in this code to make it work.

    function ocdi_after_import_setup() {
         // Assign front page and posts page (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( 'ocdi/after_import', 'ocdi_after_import_setup' );
Viewing 1 replies (of 1 total)
  • Plugin Author Gregor Capuder

    (@capuderg)

    Hi @arzubrov,

    something like this should do it:

    
    function ocdi_after_import_setup() {
         // Assign front page and posts page (blog page).
        $front_page_id = get_page_by_title( 'Home' );
        $blog_page_id  = get_page_by_title( 'Blog' );
        $shop_page     = get_page_by_title( 'Shop' );
     
        update_option( 'show_on_front', 'page' );
        update_option( 'page_on_front', $front_page_id->ID );
        update_option( 'page_for_posts', $blog_page_id->ID );
        update_option( 'woocommerce_shop_page_id', $shop_page->ID );
    }
    add_action( 'ocdi/after_import', 'ocdi_after_import_setup' );
    

    Take care!

Viewing 1 replies (of 1 total)
  • The topic ‘Can you help with the code’ is closed to new replies.