WordPress applies ltrim
on the $file
— ltrim( $file, "https://wordpress.stackexchange.com/" )
, so it becomes inc/template-tags.php
instead of /inc/template-tags.php
.
So within your filter callback, you should use:
if ( $file !== 'inc/template-tags.php' )
UPDATE
my child version has the adjustments
I don’t know if you made adjustments to pluggable or non-pluggable function(s) in the template file, but as pointed by @JacobPeattie, you should consider extending parent theme functions like so:
-
For pluggable functions such as
twentyseventeen_posted_on
, just copy the whole code and paste it in yourfunctions.php
file. And then just make your adjustments.Pluggable functions are defined like so, where the function is wrapped inside a conditional which checks whether a function with the same name already exists or not, and if not, the function is defined:
if ( ! function_exists( 'function_name' ) ) : function function_name() { ... } endif;
-
For non-pluggable functions such as
twentyseventeen_front_page_section
, follow the same steps above (copy the function code to yourfunctions.php
file), but make sure to rename the function — e.g.my_theme_front_page_section
ormy_twentyseventeen_front_page_section
.And after you renamed the function, make sure to change the name in template files where the function is being called. For example,
twentyseventeen_front_page_section
is being called in the front page (front-page.php
) template, so you’d changetwentyseventeen_front_page_section( null, $i );
tomy_theme_front_page_section( null, $i );
(if you renamed the function tomy_theme_front_page_section
).
I could understand that it might be a hassle to do the renaming part, but particularly for pluggable functions, you don’t need to override the template file using the parent_theme_file_path
filter (or similar filter). The function(s) you’re trying to modify might also actually have filters you can simply hook into to customize/change the function output, so be sure to check that. 🙂