Late answer, but in WordPress 4.7 two new functions were introduced to address this question.
get_theme_file_path()
(for absolute file paths) and get_theme_file_uri()
(for URLs) work just like get_template_part()
in that they will automatically look in the child theme for that file first, then fallback to the parent theme.
In your example, you could rewrite it using 4.7 to look like this:
/**
* Load Custom Post types file.
*/
require get_theme_file_path( 'inc/post-types.php' );
More information here: https://make.wordpress.org/core/2016/09/09/new-functions-hooks-and-behaviour-for-theme-developers-in-wordpress-4-7/
Related Posts:
- Childs PHP files not overwriting Parent’s PHP files
- why is translation not working on theme?
- Is it possible to disable a function of a parent theme?
- How to override an unpluggable parent theme function?
- How do I remove a require_once admin panel from the parent theme from the child theme functions.php?
- is there a simple way to list every templates / php files used to generate a specific page?
- Copyright info change in Theme Child PHP
- Add footer.php to WordPress child theme
- Setting up the child theme so as to enable right-to-left WordPress?
- How to override a non pluggable and non hookable function in a WordPress parent theme?
- Understanding WordPress child theme custom JS loading
- Understanding child theme functions.php
- How to stop PHP code running when in a child theme
- Overriding a theme redux file in child theme
- Want to create Child theme, but already edited Parent theme css files and some php files
- child theme inherticance and php autoload
- How do I target the child theme with get_bloginfo();?
- Deregister and Dequeue Stylesheets From a Plugin and Enqueue a Child’s Stylesheet/s
- Adding tawk.to code just before body tag on functions.php file
- Can’t extend some core classes
- WordPress child theme fails to override parent navigation menu in /inc/structure/header.php
- Where to edit the template that is generating the code for dynamic_sidebar left-sidebar in the Understrap theme? [closed]
- Parent theme CSS overriding child CSS rules
- How to style options page in dashboard?
- Replace part of a parent-theme customizer in the child-theme
- two columns of posts on homepage, one of them “favorites”
- How to edit php files in Child Theme?
- WordPress Child Themes
- Custom Background by Page IDs
- Copyright info change – Corporate Plus Theme PHP [closed]
- Started getting warning message following host’s PHP upgrade
- Why does the Woocommerce grouped template prints the unpublished products?
- How to edit HTML of my website on WordPress? [closed]
- Divi change project category slug
- How to specify the path for require_once in a child theme?
- Warning: printf(): Too few arguments in helpers.php file
- What’s a good way to allow overwriting files within a child theme if I want the same folder structure?
- WordPress filter load_textdomain_mofile not working inside a child theme’s functions.php but works form inside a plugin
- How do I check or test a WordPress Auto Year Change Script?
- Use custom template on custom post type
- How to have different site identity logos on each page on Astra Theme [closed]
- Include style.css in the Child Theme with PHP
- Problems clearing cache
- Removing “Powered by” footer using child theme PHP [closed]
- Overide Variable in Child Theme
- child parent styles enqueue order
- Creating a child theme after numerous edits to parent theme
- using wp enqueue style to create a CSS file specifically for a page template
- How to style injected code in header section?
- Where should I copy a PHP file from wp-includes to, in order to override it in my child theme?
- Child Theme’s Read More Text
- Need advice on theme customizer and child themes
- Conditionally remove comments and post meta in functions.php
- Trying to change featured image from 180×180 to full width on home page
- How to edit background color of only one sidebar?
- Inline CSS header style priority function.php Child (no enqueing I think)
- Why would the child theme load in the Customize preview, but not on the site itself?
- Proper way to remove html code on child theme
- Child-Theme Category View with modified permalinks (%category% removed)
- remove_action from parent theme using child theme functions.php
- File from parent theme imported to child theme doesn’t work – any ideas?
- How to change this ajax function to submit to the default wordpress content area instead of the custom field ‘seller notes’?
- Child theme overirde template-tags in a theme built on underscores in inc/template-tags
- PHP “warning include_once(): Failed to open stream” Simple HTML DOM in WordPress Child Theme
- AJAX numerical pagination problem in TwentyFifteen-child theme
- How to change the structure/order of sections in a WordPress theme? [closed]
- How to edit button permalink inside function.php using a child theme?
- How to locate parent theme functions and add functions to my wordpress child theme?
- How to let mobile navigation menu close when link is clicked?
- how to add functions to my function.php using a child theme?
- Modifying child theme’s header
- How to Change Site Elements based on referring URL
- WordPress files break if I edit them, but adding a closing PHP tag fixes it
- Add the shortcodes from the enfold theme to the other theme
- If i use a child theme to add new code blocks to header.php, how does it get inserted in the right place in parent’s header.php?
- WordPress child theme, creating a custom php template page
- How to override html codes in wordpress?
- random woocommerce categories are not showing when count enabled?
- Add Text Area To Child Theme’s Home Page
- Local WordPress from Git repo, where to set document root?
- Adding custom PHP to existing loop in Genesis
- Where to find the html for WordPress site? [closed]
- Child theme functions.php file change database entries
- How to remove image on single product and get product to span page?
- Removing get_template_part in child theme
- Modify arguments for parent theme’s `wp_register_style` via child theme
- Child theme not working properly
- If I define a variable in header.php, how do I make it available to templates?
- Child-theme suddenly stopped working [closed]
- Divi – add title to mobile menu button
- How can I use AJAX in child theme template?
- Add custom field to attachments in a specific category
- Different Webhost and using Google Mail server: Is there a better way than SMTP?
- Can’t print Yoast meta description into page template (syntax error, unexpected ‘.’) [closed]
- Utilize Function in Child Theme / Template File
- Order BY Most Liked And Published Between Previous Week Monday And Next Week Monday
- Unable to access WordPress functions from functions.php
- Shortcodes not processing inside post content
- get_filtered_term_product_counts – Get product terms if any products
- Particular meta tag – viewport – insertion when dealing with plugin