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
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
You 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.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0