The pages like “about” will be created automatically when a new blog is created. Likewise I need some other pages which should appear automatically when a blog is created under my multisites.
How can I configure the default pages to be created with a new blog under a multisite?
For ex.: If I have a multisite on example.com
. Every blog created under this site should have
Home, About, My store, My address.
I recommend creating a function in your functions.php file that ties to the action hook
activate_blog
. Use the WordPress functions get_pages() to see if your default pages exist. If they do not, create them with wp_insert_post.To test this function on your own site, try setting the hook to
wp_head
. It will run on each page load and insert the pages that don’t exist, with the content in $my_post[‘post_content’]. *Does the ‘activate_blog’ hook run when blogs are created in a multi-site context? I don’t know.*Refer to the codex page for wp_insert_post that I linked to for the complete list of default parameters available.
use “wpmu_activate_blog” instead of “activate_blog”. it worked for me.
thanks