Jump to content
davemoppert

Multisite - Serving The Same Header And Footer Content On Multiple Child Themes?

Recommended Posts

davemoppert    6
davemoppert

I have a multisite wordpress install using the Pagelines Framework theme. I have created two child themes for Pagelines -- one for the parent site and one for the sub sites. I am trying to get the sub sites to display the same header and footer content as the parent site. Because Pagelines populates it's header and footer content dynamically based on Pagelines settings for each site (and not hard coded), is there any way to serve the header and footer content from the parent site to all of the sub sites?

Anyone got an idea on how to accomplish this?

The parent site (using pagelines child theme: kid 2 kid) is here: http://updated-kid2kid.com
the test subsite (using pagelines child theme: kid 2 kid stores) is here: http://updated-kid2kid.com/test

My logic is that there might be some code I can add to a header.php file for the /test child theme that will display the header content from the parent site... Open to ideas!

Thanks!

  • Like 1

Share this post


Link to post
Share on other sites
dokether    4
dokether

My recommendation would be that, instead of coding into a header.php file and possibly messing up Pagelines, use the appropriate hooks:

 

pagelines_register_hook('pagelines_before_site');
pagelines_register_hook('pagelines_after_footer');

To use these, you would do something like this:

add_action('pagelines_after_footer','myfunct');
function myfunct(){
	echo '<h1>Test</h1>';
}

That would output an <h1> with the word "Test" in it at the very bottom of the website. Then you would just change the 'pagelines_after_footer' and 'myfunct' to reflect the pagelines_before_site hook and whatever you wanted for the function name. This would allow you to have whatever is included in the functions automatically included in the header/footer of every site.

Share this post


Link to post
Share on other sites
davemoppert    6
davemoppert

Hi dokether,

 

I thought about hard coding hooks right into the functions.php file for the child theme, but I would like the content in the header and footer to populate dynamically -- so if the admin changes the header (with the navigation and branding) on the parent site, that change would reflect on all the sub sites dynamically.  I don't want to hard code in the header and footer on the base theme for the subsites because I am trying to make this site as turn key as possible for the client when I deliver it.

 

I am using child theme for the parent theme and a separate child theme for the subsites.  

 

Catrina, I will try out that plugin and respond with the outcome.  Thanks for the heads up about it.  

 

Thanks for the response guys!

Share this post


Link to post
Share on other sites
dokether    4
dokether

Well, the thing is that you can still do that the way I shared. Instead of putting your code into the function() though, you could simply do an include.

 

Let's say you have your header and footer in a directory structure like this:

wp-content
   plugins
   themes
      global_header.php
      global_footer.php
      pagelines *THEME*
      child1 *THEME*
      child2 *THEME*
      child3 *THEME*

 

Then you could have your hook called in your functions.php for your child themes as such:

add_action('pagelines_after_footer','myfunct');
function myfunct(){
	include "../global_footer.php";
}

I haven't tested it out, but that should work. Then you would be able to edit just global_footer and global_header php files anytime you want to update the header/footer.

Share this post


Link to post
Share on other sites
Simon    247
Simon

There is of course a far easier way ;)

 

Wordpress has a secret folder called mu-plugins, if you add it to wp-content and put a php file in there wordpress will auto run it, no need to activate and it runs on every site! mu is Must Use.

 

So add your footer action in there and it'll run on every site.

Share this post


Link to post
Share on other sites
davemoppert    6
davemoppert

Thanks guys!  It is now obvious there are a number of ways to hard code a Header and Footer on all the subsites -- If I am understanding correctly, all of these ways require me to hard code the header and footer. That would be all fine and dandy except - I am wondering if there is a solution that will pulll the header and footer content from the parent site dynamically.  The only reason I am wondering this is because the menu on the parent site (which is located in the header and footer) will most likely change regularly.  I would love for when the client makes those updates to the menu (from the parent site), the menu options in the header and footer on all the subsites will change dynamically as well.  I am trying to make the site as turn key as possible for the client and would like the navigation menu to be editable via the admin panel of the parent site.

 

If I am understanding correctly:

 

dokether - I think I am following, but it seems this solution I would have to hard code the header and footer right? Is there any way to reference the menu navigations from the parent site dynamically

 

catrina - tried out the plugin.  It's pretty cool but unfortunately, I have to hard code HTML for the header and footer still... Is there any way to reference the menu navigations from the parent site dynamically

 

Simon_P - I have never heard of mu-plugins... not sure how to implement the header and footer from the parent site on all the subsites using Must Use.  Can you clarify?

 

I think we are close... I feel like there has to be a way to do this, but am just not well enough versed in all that is wordpress :)

Share this post


Link to post
Share on other sites
Simon    247
Simon

This would insert a comment into the <head> of every site.

add_action( 'wp_head', 'my_header' );
function my_header() {
    echo '<!-- this is on all sites in the <head> -->';
}

Share this post


Link to post
Share on other sites
davemoppert    6
davemoppert

Simon_P - I could totally add this code in the the functions.php file of the child theme for all the subsites, but I would still have to hard code the menu in the header right?  Is there some code that I can use that will serve up the navigation menu from the parent site OR do I just have to hard code it and manually change the code in this function every time there is a change in the menu (which is what I am trying to avoid)? I am trying to make the site as turn key as possible for the client and would like it when ever the navigation menu is changed (via the wordpress admin panel on the parent site) those updates are served up dynamically on all the subsites (without me having to change the code every time).

 

Is there a solution for this?

Share this post


Link to post
Share on other sites
Simon    247
Simon

You want the menu the same on all subsites? How will a user navigate from inside the subsite if the menu links are all for the parent site?

Share this post


Link to post
Share on other sites
davemoppert    6
davemoppert

Yeah, so it will display the header and footer of the parent site before and after the subsite content.  I still want the subsite to have it's own menu, it will just not be the primary menu... does that make sense? Here is a screen cap to illustrate what I hope to accomplish:

 

WebsiteSUBSITES1.jpg

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Similar Content

    • flourishdesignstudio
      By flourishdesignstudio
      I am working on a multisite installation and had some questions regarding the themeing options. All the sites will have the same structure but each individual site would need a different h1 font and link color. I had originally thought that I would program/edit the parent theme to have a certain set of templates, font sizes, etc. and then that would feed to all the individual sites where I could activate the child theme and use the child theme to define the individual sites' specific link color, heading fonts, etc. So, what I was shooting for was:
      Parent theme = shared by all sites
      Child theme = specific to the minor customizations on a per site basis.
      Is this possible? Am I misunderstanding how these would actually deploy to the different sites?
    • jagipson
      By jagipson+
      Should be a simple answer but not sure why its not doing this.  I have a child theme installed on pagelines 5 that has a hook so it will write over the theme css. Strange is that when I am on the frontend the code works but in the dashboard your theme takes over my code and its no where to be found. See examples attachments
      @Andrew @Danny


    • TallTree
      By TallTree+
      Hi,
      I am trying to remove the sidebar areas from my child theme (pagelines.com) from the post pages on a site:
      https://staging4.talltreemusicfestival.com/2017/grand-analog/
      The content is all the way to the left and very small, and the two sidebar areas are taking up a lot of space.
      What I'm after is content to the left, taking up most of the space, and then a small sidebar width on the right for widgets.
      I've tried selecting 'read width content' and 'full width content' in the edit screen for the WP content section, but it doesn't change.  If I try to move the sidebars (1 or 2) to the left, it doesn't change.
      If I select the pagelines framework theme (not child), the two sidebars go away when not selecting them in the edit screen..
      Can someone please tell me what I'm doing wrong?
      Thanks in advance.
      -Matt
       
    • dbrowne02
      By dbrowne02+
      Hi, I noticed that framework and pagelines.com child theme has a number of errors when run through themecheck. The others, like material and bootstrap, don't have any errors when run through theme check. Is there a way to get it so that there are no errors on the child theme?

×