$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>Hwo to turn off "get_parent_theme_file_path" in child-theme?|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Hwo to turn off "get_parent_theme_file_path" in child-theme?

matteradmin11PV0评论

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 badges
Add a comment  | 

2 Answers 2

Reset to default 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.

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.

Post a comment

comment list (0)

  1. No comments so far