1

Is it possible to make a wordpress multisite on domain.com and then every site that I make goes to domain.com/directory/newsite?

and then I have another question: is it also possible to that every new site has no content, so the whole site is empty?

2
1

Is it possible to make a wordpress multisite on domain.com and then every site that I make goes to domain.com/directory/newsite?

no, this is not possible without some major code hacking as far as I can tell. I run a few multisites, and I have some local installations to play around and didn't manage to find a way to do this within the exsiting process-flow, although I would be happy to be proven wrong.

However, there is a way to achieve a similar result with a single-site installation in the root directory and a multisite sub-directory installation in a sub-folder. This would give,

  • domain.com as the single site installation in the root folder.
  • domain.com/folder/ as the main site of the sub-directory multisite installation which would need to be redirected back to the domain.com.
  • domain.com/folder/site1
  • domani.com/folder/site2...

the downside of this approach is that it would create 2 separate dashboards and 2 separate DBs, although it would be easier to maintain/upgrade on the long-term than a hacked WP multisite installation.

and then I have another question: is it also possible to that every new site has no content, so the whole site is empty?

by this question I am assuming you mean no pages/posts which are created by default on creation.

When a new site is created the wp_insert_site action hook is fired, so you can use that to clear your content with the switch_to_blog function call. I would use wp_delete_post as there is only 2 posts to delete.

add_action('wp_insert_site', 'clear_site_content',10,2);
function clear_site_content($new_site){
  switch_to_blog($new_site->id);
  wp_delete_post(1, true);
  wp_delete_post(2, true);
  restore_current_blog();
}

if you use wp_cli there is the function wp_site_empty which you could use to the do the same thing, but that is over-kill in my opinion.

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.