I have the Twenty Seventeen theme and I would like to turn off generate SVG (social icons menu) in DOM.
.png
How can I turn off it? I do not use the social icons, but it is g
In function.php my parent theme i see it:
require get_parent_theme_file_path( '/inc/icon-functions.php' );
How can I override it in my child-theme to avoid generate it?
Thank you in advance.
I have the Twenty Seventeen theme and I would like to turn off generate SVG (social icons menu) in DOM.
https://i.sstatic/FYb49.png
How can I turn off it? I do not use the social icons, but it is g
In function.php my parent theme i see it:
require get_parent_theme_file_path( '/inc/icon-functions.php' );
How can I override it in my child-theme to avoid generate it?
Thank you in advance.
Share Improve this question edited Jan 9, 2019 at 18:49 fuxia♦ 107k39 gold badges255 silver badges461 bronze badges asked Jan 9, 2019 at 18:24 kibus90kibus90 1512 silver badges10 bronze badges2 Answers
Reset to default 2If you look at get_parent_theme_file_path()
it returns apply_filters( 'parent_theme_file_path', $path, $file );
You need to add a filter here to override the location to something in your child theme, like so.
add_filter('parent_theme_file_path', function($path, $file) {
if ($file !== '/inc/icon-functions.php') {
return $path;
}
$path = get_stylesheet_directory() . '/' . $file;
return $path;
}, 10, 2);
You will still need to have a file for it to find at that location in your child theme, but you can put whatever you want in there.
Create /inc/icon-functions.php
file in your child-theme and modify it as you want!
EDIT
You must hook to the parent_theme_file_path
to tell wordpress load file from child theme, so use the following code:
function override_parent_theme_file($path,$file) {
if ($file == '/inc/icon-functions.php')
return get_stylesheet_directory() . '/' . $file;
}
add_filter('parent_theme_file_path','override_parent_theme_file',10,2);
Also you can remove the if statement if you want override to other files included this way.