Can i pass custom info with new blog templates

I found this cool idea on stack for passing the content of the page into the associative array.

Can this work somehow with new blog templates?

If I turned off pages; perhaps it will work and the menus still work. I'd rather not though as nbt can do custom sidebars; etc.

But what do you all think? Any way to put this after?

http://wordpress.stackexchange.com/questions/116715/different-page-content-for-default-pages-on-wordpress-multisite

  • Ignacio

    Hi @in-mn.

    Sorry for the late here. You can use that method, I think, I have not tested it but it seems fine. However you'll need to do some custom code for that. Activating/deactivating pages options will not change anything:

    add_action( 'blog_templates-copy-after_copying', 'your_function_name', 10, 2 );
    function your_function_name( $template, $blog_id ) {
       global $wpdb;
       $wpdb->query( "DELETE FROM $wpdb->posts WHERE post_type = 'page'" );
       // Now the code you found in stackoverflow
      switch_to_blog( $blog_id );
      $default_pages = array(
           'Contact'     => "This is your 'Contact' page. Enter in your content here.",
           'Information' => "This is your 'Information' page. Enter in your content here.",
           'About'       => "This is your 'About' page. Enter in your content here.",
           'Home'        => "This is your 'Home' page. Enter in your content here.",
       );
    
       if ( $current_pages = get_pages() )
           $default_pages = array_diff( $default_pages, wp_list_pluck( $current_pages, 'post_title' ) );
    
       foreach ( $default_pages as $page_title => $page_content ) {
           $data = array(
               'post_title'   => $page_title,
               'post_content' => $page_content,
               'post_status'  => 'publish',
               'post_type'    => 'page',
           );
    
           wp_insert_post( add_magic_quotes( $data ) );
       }
       restore_current_blog();
    }

    I think it should work.

    Regards.
    Ignacio.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.