I want to wrap an additional div around the h4’s in my footer widgets. I searched through the files and found that it is set in /public_html/wp-content/themes/bb-theme/classes/class-fl-theme.php.
I’m using the Beaver Builder child theme. I was wondering how I can override the function code? I’ve tried copying the entire file class-fl-theme.php with my edits to the child theme /classes folder but it didn’t work. I also tried copying the entire function and pasting it into class-fl-child-theme.php but that didn’t work either.
For your reference, the code snippet below demonstrates what I’m trying to achieve in terms of the ‘before_widget’ and ‘after_widget’ additions.
// Footer Widgets
if ( $footer_widgets_display != 'disabled' ) {
register_sidebars( 4, array(
'name' => _x( 'Footer Column %d', 'Sidebar title. %d stands for the order number of the auto-created sidebar, 4 in total.', 'fl-automator' ),
'id' => 'footer-col',
'before_widget' => '<aside id="%1$s" class="fl-widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<div class="footer-title-container"><h4 class="fl-widget-title">',
'after_title' => '</h4></div>'
) );
}
Hey Geoff! You’ll probably want to override the whole footer.php file in your child theme. As you noticed, you can’t over ride the theme class in a child theme, but you can create a child theme class and copy/paste the functions code over and adjust them there.
So, in short, create a footer.php file in your child theme, copy the functions that create the footer widgets into a child theme class (or, just copy the markup directly into your footer.php file), then call your function instead of the parent theme’s function.
Let me know if that’s clear. I can elaborate if you’d like!
Thanks for the quick reply. Yes if you don’t mind explaining a little more. I can see various calls in the footer.php file, but I’m not clear on which one I’d need to change and how I’d get it to look at my class-fl-child-theme.php file rather than the parent’s class-fl-theme.php - which I think is what you were getting at?
Also, apologies but I realise I should have posted this in Beaver Builder Theme forum, please feel free to move it.
Hi Geoff! Sorry for the delayed response. Sorry, but after taking a closer look this might be a bit trickier than I first thought. Can you explain why you want the extra div? I am wondering if there might be a simpler solution. Let me know.
Hi, one thing I don’t understand is that on a child theme you can normally specify the same file, in the same folder structure, and the theme will use that instead of the parent version. Couldn’t this happen on beaver? So we could add a class-fl-theme.php to a /classes folder in our child theme and customise it. Otherwise there’s no way of customising the structure/class names used in the footer widgets?
To answer your question, check out the titles on this page http://goo.gl/3Lvdqe - notice that we have a border on the h4 and also a border on the <div> that wraps the h4. We wanted to do this to the two footer section headers. We assumed it would be easy enough to alter the HTML/CSS that is hard coded in to the class-fl-theme.php footer section.
Geoff, you’re right about overriding files in child themes, but it only works for template files. It won’t work if you try to override the FLTheme class.
Thanks for sending the example. After looking at it, I would recommend not setting a title on the widget and just adding the markup in the text area of the widget. Then you could adjust that markup as needed. Here’s a screenshot:
Yes I guess there’s no reason that wouldn’t work, I’ll give it a try.
In terms of the other point about overrides. We’ve used other themes in the past, where they’ve been programmed to check the child theme directory for any file, both template and function / include files. If the theme finds a file with the same name in the child directory (in the right sub-folder) then it will use that file instead of the parent’s version. This gives you a huge amount of flexibility to override theme functions etc. Is there a reason this isn’t the set up with Beaver?
PS. Could you move this thread - I don’t mind the screenshot above, but would prefer it not be public, so if this was in Beaver Theme support I’m assuming that is paid members only?
Geoff, sure thing. I moved the thread and I went ahead and removed the screenshot now that you’ve seen what I meant.
Regarding the child theme overrides, we generate a lot of the theme’s markup from the FLTheme class. It’s called many many times and it is a critical part of the theme. We don’t want people to override it because then it would not get updated. It is possible to override the individual function calls with your own like I described, though.
It is possible to override the individual function calls with your own like I described, though.
I’m not sure I understood how to do this though and I thought your later reply suggested it would be quite complicated? I thought we could copy the function out of the FLTheme class, rename it to something custom, put that edited function in to class-fl-child-theme.php and then finally call it via a customer footer.php.
It’s the last bit that I was need guidance on, how do we get the footer.php to call our version of the footer widget function rather than the original parent one?
You would need to register your own sidebars, then override the functions that generate the footer widgets. That was the complicated bit. It’s much easier just to insert the markup in the text widget.