admin管理员组文章数量:1332619
How would I replace this function that lies inside inc/template-tags.php
in my parent theme
function theme_navigation() {
?>
<div id="theme-nav-container">
<nav id="site-navigation" class="main-navigation">
<?php wp_nav_menu( array('theme_location' => 'theme-studios-primary', 'menu_class' => 'sf-menu', 'fallback_cb' => false, 'walker' => new theme ) ); ?><div class="clearfix-pro"></div>
</nav>
<div class="clearfix-pro"></div>
</div>
<!-- close #theme-nav-container -->
<?php
}
There is no add action that it is hooked on to, there is no check to see if the function already exists. How would I replace it without touching the parent theme. I have removed much of the code in the function for brevity but I think it still makes sense.
Thanks ahead of time
How would I replace this function that lies inside inc/template-tags.php
in my parent theme
function theme_navigation() {
?>
<div id="theme-nav-container">
<nav id="site-navigation" class="main-navigation">
<?php wp_nav_menu( array('theme_location' => 'theme-studios-primary', 'menu_class' => 'sf-menu', 'fallback_cb' => false, 'walker' => new theme ) ); ?><div class="clearfix-pro"></div>
</nav>
<div class="clearfix-pro"></div>
</div>
<!-- close #theme-nav-container -->
<?php
}
There is no add action that it is hooked on to, there is no check to see if the function already exists. How would I replace it without touching the parent theme. I have removed much of the code in the function for brevity but I think it still makes sense.
Thanks ahead of time
Share Improve this question asked Jul 11, 2020 at 14:34 Anders KitsonAnders Kitson 1571 silver badge9 bronze badges 2 |1 Answer
Reset to default 2You can't replace the function, but you can substitute it:
- Copy the function to your child theme's functions file.
- Rename the function.
- Modify it as needed.
- Find the template file that references it, such as header.php, and copy that to your child theme.
- In your child theme's new template file replace the reference to the original function with your renamed version.
本文标签: filtersHow would I go about replacing this function in my child theme located in inctemplatetagsphp
版权声明:本文标题:filters - How would I go about replacing this function in my child theme located in inctemplate-tags.php 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742271430a2444377.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
theme_navigation
with a child theme file. – Hans Commented Jul 11, 2020 at 15:17