I’m going to build my first Child Theme. I understood how to override functions (hope!), but how to override variables?
For example, in a Premium Template I want to change the values of feed variables shown in functions.php:
$app_rss_feed = 'http://xxx.rss';
$app_twitter_rss_feed = 'http://yyy.rss';
$app_forum_rss_feed = 'http://zzz.rss';
But if I create my functions.php file inside my child theme and assign a different RSS feed value to these variables… nothing happens.
So, which is the right way to change variables?
I’m mobile, so this will be short.
Use the after_setup_theme hook to add a function to set those variables. Declare them as global inside that function before setting them.
Hope that helps.
If anybody wants to add an example to this answer before I get home, feel free. 😉
The parent theme’s
functions.php
is loaded later, it will overwrite those variables. Show us the code where these variables are declared and where thex are used, there may be a filter you could use.An example: In
fetch_feed()
you can filter the feed URL:To filter the values, you could check for the parent theme’s URL:
Not tested, just an idea.