thetrickster / FoundationPress-child

Child theme for FoundationPress Wordpress/Foundation starter theme at https://github.com/olefredrik/FoundationPress
22 stars 13 forks source link

navigation.php in child theme incorrectly used alongside navigation.php of parent theme? #19

Closed ronenschmitz closed 9 years ago

ronenschmitz commented 9 years ago

Hi again Chris,

in my FoundationPress child theme I have added these lines to functions.php:

// Register all navigation menus require_once('library/navigation.php'); // Create widget areas in sidebar and footer require_once('library/widget-areas.php'); // Add theme support require_once('library/theme-support.php');

I have added this 3 filed into the library of my child theme, and altered the code of parent theme original to meet my child theme needs.

Now, when I go into WP Admin/ Themes/ Preview/ Navigation, my own navigation menus appear alongside the default navigational menus of the parent theme? I had expected that, the presence of a file (i.e. /library/navigation.php in this case) would mark the original file in FoundationPress irrelevant. But now they add up. Where am I going wrong?

Thanks for any help! Ronen

ronenschmitz commented 9 years ago

Might that be actually related to my other Issue poste here: https://github.com/thetrickster/FoundationPress-child/issues/18 ?

ronenschmitz commented 9 years ago

We'll anyways: After reading this, http://foundation.zurb.com/forum/posts/19765-foundationpress-child-theme I am done creating a child theme of FoundationPress, and that'll probably save me a lot of time. Also, in this article, it says that this child theme is outdated. Thanks anyways.

thetrickster commented 9 years ago

When I first created this project the common theory was that Foundation Press should be the basis of a custom theme and that you shouldn't create a child theme at all so this is a rogue project in a sense. My feeling was that while some folks were ok with just updating the Foundation elements of the Foundation Press theme by running the foundation update command from the project that wasn't updating the actual theme code and my goal was that in by creating a child theme I could update the Foundation Press parent theme via git. I thought it was neater.

But yes, this child theme is probably out of date- but its still probably quicker to clone this to start your child theme and get it rolling-- it has the basics but has not been updated along with the Foundation Press theme so it might not work correctly outright as of this moment. I'll be putting a note on the project page asking for help in maintaining the project to keep it up to date and improve it.

thetrickster commented 9 years ago

As for answering your original question just so you are aware-- you can copy the code in the library folder just as you did and make edits to those files and they WILL override the parent theme functions.

BUT- you can't require those files again in your functions.php file. Since the original parent theme has those files required already to include it in the parent theme, your child theme will show the nav menus already by default because the parent theme has already established it.

The functions.php file functions differently from other php files in WP. Typical child theme template files behave that WP will try and load your child theme's page.php file if there is on in the child theme. But when it reads functions.php it read it after your parent theme's functions.php file. So- in your case, those functions to include the navigation elements and everything are already in there.

Just remove the require lines from your child theme should you decide to use it anyway.

ronenschmitz commented 9 years ago

Thank you Chris. That was very helpful understanding the core of how things mend together. Even though I still go on now with the parent theme. Keep up the good work, and thanks for replying so quickly.