admin管理员组文章数量:1122846
I would like to overwrite some content which is located in (inc/
) template-tags.php
file on parent theme.
Content need to be changed is in function footer_content_widget_area
in template-tags.php
file and that function is called on functions.php
:
add_action( 'page_widgets', 'footer_content_widget_area' );
I would like to overwrite some content which is located in (inc/
) template-tags.php
file on parent theme.
Content need to be changed is in function footer_content_widget_area
in template-tags.php
file and that function is called on functions.php
:
add_action( 'page_widgets', 'footer_content_widget_area' );
Share
Improve this question
edited Mar 13, 2017 at 14:38
Ethan Rævan
4,0295 gold badges27 silver badges55 bronze badges
asked Mar 13, 2017 at 14:12
Roger WayneRoger Wayne
2236 silver badges13 bronze badges
2
|
2 Answers
Reset to default 0In functions.php
child theme include template-tags.php
from parent theme:
require_once get_theme_file_path( '../parent-theme/inc/template-tags.php' );
In the child theme template-tags.php
remove parent action and add the child action replacing it:
remove_action( 'tag', 'parent-function', 0 );
add_action( 'tag', 'new-child-function', 10 );
As long as you have a child-theme setup correctly then you just allow the child-theme to replace the parent-theme template by placing the template file in the same location.
So based on the location that you mention in your question you would simply place your edited copy of the template-tags.php in the location child-theme/inc/
the wordpress way of things is explained in the Template_Hierarchy (https://developer.wordpress.org/themes/basics/template-hierarchy/).
本文标签: Overwrite templatetagsphp in child theme
版权声明:本文标题:Overwrite template-tags.php in child theme 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736288126a1928029.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
template-tags.php
? – Milo Commented Mar 13, 2017 at 16:25