Update a structure file in the child theme
-
Hi there. I need to make some structural changes on a client’s website that uses a Generatepress theme, and these changes needed to occur in the navigation.php file that is located within the ‘inc/structure’ folder. However, if I duplicate these folders and files within the child, none of the changes take effect, but they do if I edit the parent theme directly which I’m trying to avoid.
Is it possible to make changes to these files so they show up within the child theme?
-
You can see the folders and file I’m referring to here in this image:
Hi there,
what changes are you wanting to make ? As GP uses Hooks that can do most things without the need to edit templates.
Hello!
I need to add a few items to the navigation such as icons for language section, contact buttons and also a search functionality.
They’d likely need to sit here within the structure:
I’ve not really used hooks a lot within WordPress – where/how are these called and how do I utilise these to make changes like those above within the Generatepress chile theme?
See here here:
the:
do_action( 'generate_inside_navigation' );is an Action Hook.You can use the
add_actionfunction to hook in your callbackhttps://developer.wordpress.org/reference/functions/add_action/
For example:
add_action( 'generate_inside_navigation', 'my_custom_function', 10 ); function my_custom_function() { // do stuff }Thanks David. So how would I use these hooks to add new elements to the navigation? Does this happen within the child theme? (e.g. via the functions file?)
The following design shows the elements that I need to add to the navigation file:
There’s a search function that sits above the navigation list and also a contact call to action that sits under the navigation list – for which I’d need to write the HTML/PHP. How would these work within a hook? Where are the existing hooks that are being called within the Generatepress theme?
So the code would go in your Child Theme functions.php
The `generate_navigation_position’ function is the one you need to hook into. See here:
Anywhere you see a ‘do_action’ you can hook into.
You’re alternative is to copy that function into your Child Theme and work from there. But personally i would use the Hook method
Aha! Got it. It’s clicked for me now and I’ve made some progress. Thank you for your help, David!
Glad to hear that!
Thanks again! I do have one last question – which file possesses the hooks for the slideout menu? I’ve checked the navigation.php and the footer.php (since the slideout menu sits under there within the HTML) but I can’t find the structure for this.
The Slide Out Menu is a GP Premium feature, and unfortunately WordPress rules forbid us from answering support topics related to a premium plugin in this forum.
You would need to own a GP Premium license to access the premium support channel for answers:
Well, that’s a bit daft as far as WordPress rules go, but the fact that it’s a premium plugin managed to direct me to the plugins folder where I found the right file so that actually indirectly helped! Thanks!
It’s actually a very positive rule – might be worth a read:
https://wordpress.org/support/guidelines/#do-not-post-about-commercial-products
Glad to hear you found a solution.
It’s not daft at all and it prevents a lot of abuse. Customer and pro features must not be supported in the community forums.
For pro or commercial product support please contact the developer directly on their site. This includes any pre-sales topics as well.
https://generatepress.com/support
As the developer is aware, commercial products are not supported in these forums. I am sure they will have no problem supporting you there.
The topic ‘Update a structure file in the child theme’ is closed to new replies.
