Your functions.php
doesn’t create output, so you should use locate_template()
.
Example:
locate_template( 'php/functions.nav-menu.php', TRUE, TRUE );
You’ll find this function in wp-includes/theme.php
. The first parameter is the file path relative to the theme root, the second tells WordPress to load it (or not), and the third to load it just once.
Now a child theme can override the file by just placing a file with the same name to the same place in its own theme root.
Related Posts:
- Using require_once for parent-directory not working but is working in sub-directories
- get_template_part vs action hooks in themes
- The proper way to include/require PHP files in WordPress
- What is the right way to include a wp-admin file in your theme?
- How can I see what template parts are being called for rendering the viewable page?
- Single Page WordPress Theme – Using page templates
- Finding Page Template and Displaying Content
- Some doubts about how to show posts in a custom theme?
- Should I use include or load_template for including shortcodes, plugins and so on?
- What is the best way to organize template parts?
- Is it possible to include an HTML flat-file website inside a WordPress theme?
- get_template_part() doesn’t work
- How do I get standard posts to open up in their own template when using get_template_part()?
- Is there a way to retrieve the calling template part?
- Is it possible to have a Theme with built-in physical page files?
- Exclude function from homepage only?
- How can I include custom Gutenberg Blocks in a theme?
- Incorrect search results in search.php – issue triggered by using `define(‘BodyID’, ‘search’); the_post();` in search.php
- Want to include ad code after related post
- WordPress Includes mejs 404 error
- Solutions for generating dynamic javascript / CSS
- Custom single template for a specific category
- Generating CSS Files Dynamically Using PHP Scripts?
- Add Caret to Menu Items with Sub-Menus in WordPress Theme
- How to get gallery images?
- Custom theme/plugin update checks
- Display admin notice only on main dashboard page
- What does “Do not deregister the jquery script in the administration area” mean?
- What is the best book to learn how to make themes for wordpress?
- Multiple Custom_Background, is it possible?
- Is there an error in get_the_tag_list()?
- Use theme folder instead of plugins_url
- Setting hero/splash section as a blog post
- How to call wp_list_comments() with callback outside the loop
- why adds ‘»’ symbol?
- Infinite Scroll not working in own theme
- How can I exclude specific authors from wp_list_authors
- how to wrap tag in tag html to wordpress menu conversion
- Understanding the WordPress template hierarchy
- How to display the content for given page ID withot the wrapper?
- Develop new theme without affecting the active one
- How to add categories to wp_list_pages()
- Force a specific template based on the URL
- Manage base theme with version control?
- How to add a download link to a movie from WP media library?
- WordPress custom post type permalink: website.com/post-name/post-id
- Using $post->post_name in body id causing error: Trying to get property of non-object
- Execute upgrade-theme with coding
- buddypress: how do i make the group description excerpt shorter?
- Can´t access child theme´s scripts dependencies found in parent
- Prefix best practice, should we use framework name or theme name?
- Theme Javascript.php Overwritten Nightly [closed]
- Using page-id-{ID} from body_class() in local dev, versus live staging
- Is there a way to visualize / print out which templates were used to render a given piece of UI?
- Custom image size vs CSS sizing
- Unique design inside a specific category’s url
- Rewrite the HTML markup of wp-login.php
- Are there any caveats to compiling all of my theme’s SCSS into the style.css file in the theme root?
- SVG in list-style-image breaks when adding fill
- Alignment Problem [closed]
- Clearing dummy data before launch
- Multiple editable areas
- Converting a static HTML template into a WP theme – How do I specify page content?
- Create new wordpress theme with no need update
- How to display date of blog creation
- Theming media inserts
- How to update mark-up of a gallery block in a custom theme?
- wordpress script_loader_tag in function.php
- Host Private Custom Theme
- Why not works the search.php file?
- My wordpress theme name isn’t updating straight away
- How do I make my terms for each product display via foreach loop? (woocommerce)
- WordPress Insert ads after every 5th post
- Theme starter content translation is not working
- Adding a second logo next to the main one in header
- (Parent) theme Is Not Showing In Theme Selection Panel and Therefore Breaks Child Theme
- How to add an image to a theme page template in code?
- Looking to create an “update theme” functionality for a custom front-end dashboard
- Text View (Code View) in WordPress Customizer TinyMCE Editor
- How to get next post and previous post URL in loop, single.php My WordPress 4.9.6
- Import settings from another theme
- Load multiple css simultaneously using functions.php
- Different stylesheet for different pages not working fully
- Can I use WP Multi-site on a sub-domain with a different theme but use all the original site’s posts/pages?
- How to Apply Category Filter to Pagination
- How do I use the add_query_arg function in a template tag like previous_post_link?
- Get all Custom Post Types
- Let users to add any number of input fields in the theme option page
- wpalchemy repeating fields dropdown issue
- Does WordPress require that your submitted theme supports multiple menu levels?
- Add custom field to existing meta box?
- Theme Options Doesn’t Work On WP Multisite
- Standard Way To Do Custom Work Within A Page?
- Subsite theme mystery man replacement with Buddypress on main site [closed]
- Why does the first loop take arguments from the second loop?
- Theme layout for home page [closed]
- Is there any reason that other theme elements (such as nav menus) shouldn’t be within the loop?
- Is there any way to show child theme in theme detectors?
- Add wrapper for a specific sub-menu
- Theme’s featured image option is not showing up