I have the Twenty Seventeen theme and I would like to turn off generate SVG (social icons menu) in DOM.


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.

2 Answers 2


If 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.

  • Thank you for your answer. Okey, but is there possibility to turn off it? Because it still generate the SVG icons to DOM...
    – kibus90
    Jan 9, 2019 at 23:38

Create /inc/icon-functions.php file in your child-theme and modify it as you want!


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;

Also you can remove the if statement if you want override to other files included this way.

  • get_parent_theme_file_path calls get_template_directory() which doesn't look in the child theme. you need to filter it to look in the child theme manually.
    – mrben522
    Jan 9, 2019 at 19:57
  • @mrben522 You are right! I updated my answer to prevent any misunderstanding for anybody. I hope you consider updating your own answer too and add a simpler way like mine! Jan 9, 2019 at 20:47
  • Hello. You code returns ERROR 500.
    – kibus90
    Jan 9, 2019 at 23:38
  • @kibus90 Maybe because you forgot to create /inc/icon-functions.php file inside child theme directory! Jan 9, 2019 at 23:46
  • I did it! :) I checked twice.
    – kibus90
    Jan 9, 2019 at 23:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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