Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am looking for a solution to reuse the header and footer navigation links (with style, of course) in one of my WordPress website for several other WordPress sites.

Please note that I'm trying to share header and footer among WordPress sites, not from WordPress site to a PHP page. The sites I'm referring to are on the same server. I have the following directory structure:

example.com/ #main site is here
   some-other-site/
      wp-admin/
      wp-content/
      wp-include/
      ...
   wp-admin/
   wp-content/
   wp-include/
   ...

I would really appreciate some direction on how to achieve this goals and best practices, if possible since I am still new to WordPress. I have a few ideas in mind but I am not sure which one is best programming practice or how much effort each approach requires (for cost benefit analysis)

1) Write a custom get_header() function in the main site's functions.php to allow extraction of navigation links file_get_contents() to get the navigation links from wp-content/themes/my-theme/inc/footer.php in some-other-site/ I use

define('WP_USE_THEMES', false);
require($_SERVER['DOCUMENT_ROOT'] . '/wp-blog-header.php');

Currently, I get "<a href="&lt;?php bloginfo('siteurl'); ?&gt;/articles/category/editorial_team">Background</a>" as output so it doesn't work for me yet.

I found one similar topic but the question is a bit unclear to me and the solution of using absolute urls is not a good practice, I was told.

2) Expose those navigation links as web service. I have a feeling that web service is not even relevant here but I still put it here just in case.

3) Use Multisite settings or create a network for all my WordPress sites. While this appears to be the best way, it seems quite complicated and there are actually issues with my main site being setup in a network currently. I doubt it's necessary to got through this complication to achieve my goal.

As far as I know, sites in WordPress network shares certain databases and therefore I'm so afraid of losing some or whole of the huge data in my main site.

It would definitely be relevant to point out the best practices in sharing CSS stylesheets and Javascripts file among WordPress sits as well, if you are kind enough :)

Sorry my long post. Thank you very much! Eric P.S.: Sorry for duplicating this post from StackOverflow.com. I have found the answers for all of my WordPress related questions on StackOverflow.com so far so I just don't know which is the more appropriate place to ask. Please advise if I need to merge the 2 topics on 2 sites. Thanks!

share|improve this question

2 Answers 2

up vote 0 down vote accepted

I would think that your best bet is option 3 (multisite) if possible. Once you've got your network of sites set up you can then specify which menu to use as described here.

Doing the other solutions (a more rough and ready 'hardcoded' approach) will almost certainly give you headaches in the future. Having multisite set up also has advantages such as ease of updating and maintenance of user base.

You're right that if you use a multisite setup, all sites use one database. You shouldn't lose any data in the handover, but you should definitely do a complete backup first in case. If you're worried, do a dry run by setting up a testing environment and exporting / importing the data using Tools > Export / Import.

share|improve this answer
    
Thank you. It looks like WordPress multisite is the right thing I have to do for long term benefits it brings. I'm just crossing my fingers that the export & import process will go smoothly as my site has a lot of data and it's already in a buggy multisite setup (which I don't know why I rather start from scratch and import old data) –  Eric Nguyen Sep 19 '11 at 9:31
    
If you're worried, you could do a dry run first before touching anything on the live sites. For example, do it on your local machine using XAMPP –  tallphil Sep 22 '11 at 13:35
    
sure, tallphil, I'm setting everything up in my local environment right now. Thanks for commeting –  Eric Nguyen Sep 28 '11 at 5:20

I would certainly suggest a multisite approach too.

Not sure if I am misinterpreting what you are asking for (and not sure if best practice) but if you are going to be using the same header/footer on all sites and they are all going to look the same (but just have different content in the middle) then it might be worth setting them all to use the same theme?

p/s: All sites on the multisite, as tallphil said, uses one database - the numbering of the (key) tables change for each site.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.