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
- Remove update nags for non-admins [duplicate]
- Error Warning: Declaration of description_walker::start_el after PHP upgrade [duplicate]
- Mega Menu Walker
- Displaying Logged-In User Name in WordPress Menu
- Autoloading in Child Theme
- How to add a class to the attachment images
- How to call a function only once (global variable scope)
- Multiple is_page() in page.php
- Set media upload attachment link to none and hide it in WP v3.5
- Fatal error: Call to undefined function plugin_dir_path()
- Switching wp_get_sites to get_sites
- Is it possible to get a theme customizer setting from wp.customize using jquery?
- How to get the registered sidebar’s name by its id?
- is there a simple way to list every templates / php files used to generate a specific page?
- Check if page parent has certain template
- Counting number of posts in a category and its sub categories and displaying result using shortcode
- Shortcode created to check language not works
- Delete post revisions on post publish
- Best way of adding CSS which can be manipulated by the user via theme option panels?
- How to Append to the_excerpt() Function
- Add/echo div with Analytics-Code to function in functions.php
- Listing all sub-pages?
- Why do filters/actions require an argument count?
- How can I default to all WordPress roles when parameter is not included in shortcode?
- How do I list the_tags() into HTML data-attribute
- WordPress if (is_page) translation on certain page
- Recent post display using shortcode
- child theme inherticance and php autoload
- Check if term object is in array
- Highlight Current Tag in wp_tag_cloud
- Getting rid of role=”navigation” in the Home Page Pagination
- Deregister and Dequeue Stylesheets From a Plugin and Enqueue a Child’s Stylesheet/s
- How to use return in my custom function instead of echo
- How to speed up a wordpress function with multiple loops?
- syntax issue on php 7.4
- How can I use wp_insert_comment to write a comment when a post is edited?
- How to remove the excerpt in the Dzonia Lite theme
- Can’t extend some core classes
- How do you add customer capability after Woocommerce purchase?
- Get first URL from post content
- Setting custom canonical urls
- Trigger popup in a php if/else statement
- Setting a cookie upon specific URL visit
- get post based on category chosen in drop down – The ajax method
- how to make separate field in wordpress user_data_
- Where to edit the template that is generating the code for dynamic_sidebar left-sidebar in the Understrap theme? [closed]
- Add a class to the anchor tag on HTML5 gallery
- Conditional Header in wordpress
- Menu — How to add “current-menu-grand-ancestor” css class
- functions.php is being included twice, creating PHP fatal errors
- Hide Hamburger Menu On Specific Page (Front Page/Home Page)
- How to put a variable in a instance in the widget
- How to output a PHP file values by shortcode?
- Set the background to a default image if there isn’t a specified “featured image”
- Calling directories to load in wordpress
- get a simple array of all of the term names that exist in all taxonomies
- Logged in user ID as post ID
- WordPress Access allowed to fewer pages till user logs in
- Show categories then when clicked on a category list all sub category and when clicked show all posts in that sub category
- How to store data from multiple forms using ajax and php
- How to control WordPress image metadata (using Imagick)?
- Use DOMDocument with ob_start breaks my HTML code
- Display a specific category of products in shop page and disable code for specific actions
- Removing “wpautop” (auto tags) only on certain pages?
- different id for same element visual composer [closed]
- Tax query in pre_get_posts not working
- trigger html cleanup for all posts
- 3 Slashes appear after Apostrophe in custom fields after updating product-site
- Validation algorithm in checkout field
- Catchable fatal error: Object of class stdClass could not be converted to string after WP 4.7