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="<?php bloginfo('siteurl'); ?>/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.
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!