For cases where you want to require/include PHP files, but still allow child themes to replace those PHP files outright, then you should use the locate_template function.
Example: Parent does this:
locate_template( 'admin/file.php', true );
This finds the admin/file.php file in either the child or the parent theme, then does a require on it (that’s what the true is for).
So to replace the file in the child, you just replace the file in the child. Simple. Easy.
Note: The method defaults to using require_once. If you just want to require only, then pass a third parameter of false.
Related Posts:
- Is it possible to disable a function of a parent theme?
- How to override an unpluggable parent theme function?
- 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
- Overriding a theme redux file in child theme
- Adding tawk.to code just before body tag on functions.php file
- WordPress child theme fails to override parent navigation menu in /inc/structure/header.php
- How to style options page in dashboard?
- Copyright info change – Corporate Plus Theme PHP [closed]
- How do I check or test a WordPress Auto Year Change Script?
- How to have different site identity logos on each page on Astra Theme [closed]
- Removing “Powered by” footer using child theme PHP [closed]
- Overide Variable in Child Theme
- child parent styles enqueue order
- How to style injected code in header section?
- Child Theme’s Read More Text
- Need advice on theme customizer and child themes
- Adding a ‘style=’ bit to image_send_to_editor output
- Proper way to remove html code on child theme
- 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
- Access to “My Site” is missing from the admin bar
- wordpress ajax return 0
- Removing get_template_part in child theme
- How to set and use global variables? Or why not to use them at all
- How to Add Image to WordPress RSS-Feed with no Plug-in?
- Childs PHP files not overwriting Parent’s PHP files
- Remove wp-mediaelement.css from wp_head
- add_filter to post-gallery and remove all ‘s?
- Set the transport of the Customizer ‘header_image’ core setting to ‘postMessage’
- show limited tags in an article
- delete an array element when its date expires
- Using a function written in my functions.php file within the header.php file
- Disable External Pingacks on WordPress Posts and Only Allow ‘Self Pings’
- Woocommerce: Is it possible to overide the settings for allowing to purchase out of stock products [closed]
- WordPress Redirect: Default Password Reset URL [duplicate]
- Admin Options page. Save as Array
- How to remove or change the “W” icon in “My Sites”?
- How to prevent WP_Query function from returning all posts when empty?
- wp_trim_words() does not work with my code Am I doing any mistake in my code?
- Woocommerce: hook action/filter I could use to add variation id and price with each attribute opt on WooCommerce Rest api
- foreach loop still echoes array
- dynamic dependent select dropdown
- Generating an nonce for Content Security Policy and all scripts – How to make it match/persist for each page load?
- getting logged in user info (wp-load.php) from parent directory
- wp-comments-post.php file returns a blank page
- Add .htm extention to a custom taxonomy
- WordPress Child Themes
- Custom gallery in wp3.5
- How to use theme function in post/page?
- esc_url( ) won’t use https
- retain querystring values when savincustom options in admin
- Where is this function’s callback getting its arguments from?
- Why does the post_type_link hook everything twice?
- Warning: in_array() null given in PHP function
- Use post ID in functions.php file adminside
- How to edit HTML of my website on WordPress? [closed]
- How to: Conditionally Enqueue JS and Stylesheets, for Custom Post Type (Single and Archive Templates)
- use loop to return blog details
- How can I count ACF sub_field with a certain value
- Fetching Initials of the Commentator in the WordPress Website
- Adding function to child theme’s function.php
- Custom posts password protect
- How to get post category list as select in front-end?
- How to use functions [closed]
- Function to call either single post or category
- WP Container Displaying Only on First Page of Archive
- Updating Metadata with Shortcode
- can’t load .po file in functions.php
- Woocommerce – Exclude variation attribute on specific variation
- How do I add a function to parent theme
- Are there any drawbacks on opening a session_start in functions.php and header.php?
- Child-Theme Category View with modified permalinks (%category% removed)
- Add Pre-Defined Value to Click Counter in WordPress
- How to move a post from one category to another
- Show data obtained from a function and place it in a shortocode function
- How to override theme’s public static function inside of a trait?
- Delete empty title_tags, find a h1 heading and echo it
- WP_Query To Display Product Of Brand On Taxonomy Page
- ajaxurl usage for a custom function
- oembed facebook link?
- Open/closed function [closed]
- How can I export data without using any import/export plugin
- Search for images that width and height is more than 500
- add a value to an external link query in searchform
- My customizer’s setting doesn’t set to the default and needed to click the control’s “Default” button before it’ll be set
- site_url() returns with additional backslashes
- Overwriting a Shortcode
- Search box background on a different page template
- WP Ecommerce: Display the “Order Notes” as column in the Sales Log [closed]
- A next page function with shortcode?
- What is the wrong with this function to enqueue the scripts and styles to the theme? [closed]
- Warning: Attempt to read property “term_id” on int – Woocommerce
- how to create twitter card without plugin in wordpress website?