0

I have a wordpress theme that I am modifying the look and feel by making a child theme.

The parent theme I am using uses the redux framework.

Im a bit new to using filters and hooks, but I want to add/modify a section on the options page.

I found a function to add sections through the child theme but I don't know how to use it.

When I include the code in my child-theme functions.php I get an error saying it can't be re-defined.

This is the example it shows in the options.php file.

Can anyone help explain how to use this function or point me to some concise explanations on how it should be used.

Thanks!

/*
 *
 * Custom function for filtering the sections array. Good for child themes to override or add to the sections.
 * Simply include this function in the child themes functions.php file.
 *
 * NOTE: the defined constansts for URLs, and directories will NOT be available at this point in a child theme,
 * so you must use get_template_directory_uri() if you want to use any of the built in icons
 *
 */
function add_another_section($sections){
    //$sections = array();
    $sections[] = array(
        'title' => __('A Section added by hook', AZ_THEME_NAME),
        'desc' => __('<p class="description">This is a section created by adding a filter to the sections array. Can be used by child themes to add/remove sections from the options.</p>', AZ_THEME_NAME),
        'icon' => 'paper-clip',
        'icon_class' => 'icon-large',
        // Leave this as a blank section, no options just some intro text set above.
        'fields' => array()
    );

    return $sections;
}
//add_filter('redux-opts-sections-twenty_eleven', 'add_another_section');
5

I'm the lead dev for Redux Framework. This is because you use the same function name. You must change the add_another_section name to something less common. Otherwise you'll always get an error. That's unfortunately a limitation of PHP. One name per function per instance.

1

I've just been trying to add to my site's parent theme's theme options from my child theme's functions.php and came across this.

The above answer didn't work for me, it seems this is now the way to do it (new filter in latest version of Redux):

add_filter('redux/options/{opt_name}/sections', 'init_child_theme_options');

Where init_child_theme_options would be a function the same as in the initial question.

And {opt_name} is the opt_name variable in your parent theme-created instance of Redux.

  • Help: How can i edit/add/delete any option on existing section from child? – anupalusoft Mar 26 '18 at 11:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.