简体   繁体   中英

How to display sub domain posts in main domain home page on wordpress?

I am new to using multiple sites handling in wordpress. I have a site say, domain.com and sub domains as sub1.domain.com and sub2.domain.com. I have installed WP with multi site option for domain.com and WP installed for sub1.domain.com and sub2.domain.com. Now, i am going to post in the sub domains, and i have to retrieve them in main domain homepage.

How can i do this? i found few plugins with which am unable to achieve my goal. the plugins i have tried wp multisite and a few more.

i found it's little bit tough job to do. can anyone give a step by step procedure to get it done.

and my .htaccess file contains the following code,

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]

So, If i change this code, will all of sub domain posts appear on main domain home page?

To display those posts, what i need to add in main domain index page?

Try adding this to an appropriate place in your .htaccess file located in Root folder of your site :

 RewriteEngine On
 RewriteCond %{HTTP_HOST} ^(.+)\.domain\.com$   [NC]
 RewriteRule ^ http://domain.com/ [L,R]

To exclude www subdomain , www.domain.com, add this line before the RewriteRule:

 RewriteCond %{HTTP_HOST} !^www\.mydomain\.com$  [NC]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM