admin管理员组

文章数量:1278912

I've created a child theme and I want to overwrite functions in inc/template-tags.php file. I thought if I copy this file and recreate folder structure in my child them then it will work but it doesn't? How to do it properly?

I've created a child theme and I want to overwrite functions in inc/template-tags.php file. I thought if I copy this file and recreate folder structure in my child them then it will work but it doesn't? How to do it properly?

Share Improve this question asked Oct 29, 2021 at 18:03 RaymondRaymond 1417 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Notice how the parent theme checks if they are already defined e.g.

if ( ! function_exists( 'twenty_twenty_one_entry_meta_footer' ) ) {
   ...
}

Then just define them in your child theme's functions.php file, to override the corresponding template tag.

It should work because the child theme's functions.php file is loaded before the parent's functions.php file that loads:

// Custom template tags for the theme.
require get_template_directory() . '/inc/template-tags.php';

本文标签: How do I override templatetagsphp in 2021 theme