project-ar2 icon indicating copy to clipboard operation
project-ar2 copied to clipboard

Child-Theme and functions

Open sennewood opened this issue 12 years ago • 5 comments

I use AR2 with a child theme for my personal modifications. Normaly a theme have one functions.php to handle all functions, but AR2 use an additional folder with additional files to add more functions.

Unfortunately, all my additional modified function files are ignored by WordPress. Or am I doing it wrong? ^^

sennewood avatar Sep 26 '12 09:09 sennewood

Which functions are not working from a child theme?

zyml avatar Sep 27 '12 19:09 zyml

For example the widget.php when I change the Feed-URL, I tried it via my child theme but nothing changes.

sennewood avatar Sep 28 '12 07:09 sennewood

I don't think you can just change it that way. You might have to create a new custom WP_Widget class with the updated feed URL and register it via register_widget() under the init action hook. Check widget.php for examples :)

zyml avatar Sep 28 '12 08:09 zyml

At http://codex.wordpress.org/Child_Themes#Using_functions.php I found this:

TIP FOR THEME DEVELOPERS. The fact that a child theme’s functions.php is loaded first means that you can make the user functions of your theme pluggable —that is, replaceable by a child theme— by declaring them conditionally. E.g.:

if (!function_exists('theme_special_nav')) { function theme_special_nav() { // Do something. } }

In that way, a child theme can replace a PHP function of the parent by simply declaring it again.

Is this an option for your theme, espacially for the libary folder?

sennewood avatar Sep 29 '12 05:09 sennewood

I believe it's more of 'it depends', since putting a conditional statement on every theme function could potentially affect its performance. Other than the method that you have mentioned there are other techniques used to make child theme development possible (eg. action/filter hooks, object-oriented implementations, etc.).

zyml avatar Oct 09 '12 18:10 zyml