Contents of functions.php file in a child theme

Hi, I’ve created a child theme and I am not sure if the required_once statement is required:

require_once DIR . ‘/vendor/hivepress/hivetheme/hivetheme.php’;

of course it would need to be adjusted to something like:

require_once DIR . ‘/…/experthive/vendor/hivepress/hivetheme/hivetheme.php’;

But is it really required or will the framework be loaded anyways?

Also, what is the recommended way to include the style.css of the child theme in experthive?

Thanks for your help!

Hi,

This is not necessary. This file can be empty at first (after that, you can add custom snippets)
The child theme must specify the parent theme in style.css

Also, please check this doc Child Themes | Theme Developer Handbook | WordPress Developer Resources

​I hope this is helpful to you.

Hi andrii, Thanks for your reply. I am familiar with creating child themes and custom coding, but I was wondering why the functions.php includes this specific line (below the code comment):

// Include the theme framework.
require_once __DIR__ . '/vendor/hivepress/hivetheme/hivetheme.php';

Of course I assume it might also bee needed in the functions.php of the child theme.

But if it’s not needed in the child theme functions.php why is it required in the parent’s functions.php? Or does the “theme framework” get loaded elsewhere when using a child theme? Sorry, I’m just confused about this specific line.

Also, the parent style.css seems to be included even if it’s not enqueued in the functions.php of the child theme. So why is it necessary to enqueue it?

Thanks!

It is not required to enqueue the parent style.css file and hivetheme.php files in the child theme. The functionality and customization from them will be available in the child theme anyway

Hi yevhen, Thanks heaps for your reply. I already assumed that, but wasn’t sure … Thank again!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.