Changes to functions.php and inc folder in child theme

Hi There,

I’m trying to create a child theme of sydney. I’m have a couple of issues because I want to change some thing in functions.php and I’m not sure I’m doing this correctly.

I would like to change the amount of footer widget available. I tried this but it doesn’t seem to work.

function sydney_child_widgets_init() {

//Footer widget areas
$widget_areas = get_theme_mod('footer_widget_areas', '2');
for ($i=1; $i<=$widget_areas; $i++) {
	register_sidebar( array(
		'name'          => __( 'Footer ', 'sydney' ) . $i,
		'id'            => 'footer-' . $i,
		'description'   => '',
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h3 class="widget-title">',
		'after_title'   => '</h3>',
	) );
}

}
add_action( ‘after_setup_theme’, ‘sydney_child_widgets_init’);

Also I would like to change some of the files in the inc folder, I also tried this but that didn’t work either:

require get_template_directory() . ‘/inc/custom-header.php’;

Hello there,

Thank you for getting in touch here.

> 1

Change the widget footer amount. I am afraid the footer widget definition can’t be overridden by that way.

You should need to manually comment out the respective widget definition in the parent theme.

//Footer widget areas
/*
$widget_areas = get_theme_mod('footer_widget_areas', '3');
for ($i=1; $i<=$widget_areas; $i++) {
	register_sidebar( array(
		'name'          => __( 'Footer ', 'sydney' ) . $i,
		'id'            => 'footer-' . $i,
		'description'   => '',
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h3 class="widget-title">',
		'after_title'   => '</h3>',
	) );
}
*/

> Also I would like to change some of the files in the inc folder, I also tried this but that didn’t work either.

It is considered as normal. It happens because those files aren’t part of the native WordPress template hierarchy.

Firstly, you should not to allow the parent theme to require custom-header.php. In the parent theme’s functions.php you will do the following:

// require get_template_directory() . '/inc/custom-header.php'; 

Now you can call that file from your child theme’s inc folder. In your child theme’s functions.php try to add the following:

require get_stylesheet_directory() . '/inc/custom-header.php'; 

I know that isn’t the ultimate solution, but there’s no other way than that. Sorry.

Regards,
Kharis

Thank you!