$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>customization - Create page when a new site in multisite network is created?|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

customization - Create page when a new site in multisite network is created?

matteradmin8PV0评论

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
Add a comment  | 

1 Answer 1

Reset to default 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' );
Post a comment

comment list (0)

  1. No comments so far