My function.php contains this:
if ( ! function_exists( 'hu_load' ) ) {
function hu_load() {
// Load theme languages
load_theme_textdomain( 'hueman', get_stylesheet_directory().'/languages' );
// Load theme options and meta boxes
//load_template( get_template_directory() . '/functions/theme-options.php' );
load_template( get_template_directory() . '/functions/init-meta-boxes.php' );
// Load custom widgets
load_template( get_stylesheet_directory() . '/functions/widgets/alx-tabs.php' );
load_template( get_template_directory() . '/functions/widgets/alx-video.php' );
load_template( get_template_directory() . '/functions/widgets/alx-posts.php' );
// Load dynamic styles
load_template( get_template_directory() . '/functions/dynamic-styles.php' );
}
}
add_action( 'after_setup_theme', 'hu_load' );
My child-theme localisation kicks in.
Thread Starter
skubko
(@skubko)
Hello,
I am missing “add_action” line in my function.php file. I have also found this article, where add_action is also present. When I added it now to my function.php, it is working correctly and the translations are back.
Why this extra line needs to be there? And another question – is it better to call it like you – “function hu_load” or as it was called on the link I now posted? – function my_child_theme_locale() ? What is the difference here?
Sorry, I wouldn’t know. Hadn’t tried that solution, but maybe that’s preferable… I’m sure someone more knowledgeable can explain.
This is fixed in v3.1.1 released today. See the release notes here.
Thread Starter
skubko
(@skubko)
Hi bdbrown,
I have just installed the update and read the release note. However, I do not understand what exactly it means to me (sorry, beginner)… As I mentioned above, when I added to my functions.php just this code:
function my_child_theme_locale() {
load_child_theme_textdomain( ‘hueman’, get_stylesheet_directory() . ‘/languages’ );
}
add_action( ‘after_setup_theme’, ‘my_child_theme_locale’ );
the translations started working correctly even before this 3.1.1 update… What should I do now? Return to the old code where I used
function alx_load() {
// Load theme languages
load_theme_textdomain( ‘hueman’, get_stylesheet_directory().’/languages’ );
// Load theme options and meta boxes
load_template( get_template_directory() . ‘/functions/theme-options.php’ );
and so on….
or should I keep it the way it is now?
The new v3.1.1 loads the language files from the child theme by default. You should be able to remove that function from your child theme.
Thread Starter
skubko
(@skubko)
I completely removed the functions.php file from my child theme. I remember that I used it in the past only for languages, so I guess it should be ok now… Or maybe, are those next lines important to keep? :)… as “Load theme options and meta boxes” for example as you see above?
If that’s all you had in your child theme functions.php file then, no, you don’t need to keep the file in your child theme. The default hu_load() function is run by the theme when the site loads. The only file required in a child theme is style.css.
Thread Starter
skubko
(@skubko)
Thank you bdbrown for this information and thanks to nchrtd for sharing his functions.php with me. This topic is resolved now.
Thread Starter
skubko
(@skubko)
Thank you bdbrown for this information and thanks to nchrtd for sharing his functions.php with me. This topic is resolved now.
You’re welcome; glad to help.