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:
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/a/28620/143279
Share Improve this question asked Nov 22, 2018 at 12:13 joq3joq3 3813 silver badges21 bronze badges 1- 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 ♦ Commented Nov 22, 2018 at 12:35
1 Answer
Reset to default 0After 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' );