How to extend a parent theme class from child theme?
-
I am using a Purchased theme, in that they have used OOP approach, looks good. But the issue I have is to get a desired result for my design I have to add some extra feature. So I am trying to extend a particular class in the Parent theme from my child theme. But I could not do that in my functions.php, getting an error says Parent Class not found. My class code is something like this
class MyClasss extends ParentTheme_Templates { public static function header() { $type = ParentTheme_Global::instance()->get_header_type(); get_template_part( 'mycomponents/headers/header', $type ); }
but I can use the same code for my class in my template file(I tried in header.php file) and it works, but I know this is not a proper way. So is there any proper method to do this. I can see in the codex:
Unlike style.css, the functions.php of a child theme does not override its counterpart from the parent. Instead, it is loaded in addition to the parent’s functions.php. (Specifically, it is loaded right before the parent’s file.)
It seems It might be because functions.php it is loaded right before the parent’s file.
So Is there any solution for this, or any workaround?
- The topic ‘How to extend a parent theme class from child theme?’ is closed to new replies.