0

I found this code to automatically create a page when a new site is created in the network. But I cannot figure out how to set which page template to be used when the page is created. I have a custom page template made which I want to use on the page that is automatically created.

I found this post explaining how to automatically create a page when a new site is made. But what about page template: https://wordpress.stackexchange.com/a/28620/143279

  • Is the name of the page and its slug always the same? If so you don't need a page template, the template hierarchy lets you use slugs in the filename already – Tom J Nowell Nov 22 '18 at 12:35
0

After the page is created and you have its ID, and before you restore_current_blog() you do this:

update_post_meta( $page_id, '_wp_page_template', 'your-template-file.php' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.