最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

content - Wordpress Multisite new sites in directory

programmeradmin4浏览0评论

Is it possible to make a wordpress multisite on domain and then every site that I make goes to domain/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?

Is it possible to make a wordpress multisite on domain and then every site that I make goes to domain/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?

Share Improve this question asked Nov 21, 2014 at 11:20 Steven de JongSteven de Jong 134 bronze badges 2
  • Did you ever work this out? – Djave Commented Nov 21, 2019 at 10:49
  • @Djave, regarding the directory name in the subsite path would this be helpful? paulund.co.uk/wordpress-multisite-with-nested-folder-paths – Antti Koskinen Commented Nov 26, 2019 at 9:52
Add a comment  | 

1 Answer 1

Reset to default 1

Is it possible to make a wordpress multisite on domain and then every site that I make goes to domain/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 as the single site installation in the root folder.
  • domain/folder/ as the main site of the sub-directory multisite installation which would need to be redirected back to the domain.
  • domain/folder/site1
  • domani/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.

发布评论

评论列表(0)

  1. 暂无评论