What you’re trying to do is possible.
When including php files, use get_stylesheet_directory()
in child themes and get_template_directory()
in parent themes.
E.g.
require_once( get_stylesheet_directory() . '/inc/myfile.php');
get_stylesheet_directory_uri()
and get_template_directory_uri()
will return URLs. Those functions are useful when enqueuing public assets such as stylesheets and JavaScript.
Also, setting allow_url_include
to Off
in your php.ini will provide better error reporting in these situations (source).
Related Posts:
- How Do I Unhook This Parent Theme Function?
- Issues with title-tag and document_title_parts
- Define custom Page Template without its own .php file
- How to influence the information displayed on widget inside wp-admin
- Implementing DNS Prefetching with WordPress
- syntax for remove_filter in parent theme with class
- Override parent theme function that is not hooked or in the functions.php file
- Remove Page Title from Static Frontpage
- Change parent theme file function in child themes functions.php
- Adding extra SVGs to TwentyNineteen child theme using class TwentyNineteen_SVG_Icons
- How to override filter in child theme?
- Gravity Forms field entries into wp_query loop [closed]
- Proper way of using functions in action hook?
- Accepted arguments value in hook functions
- Get current page_id before loop, in functions.php
- Which action hook to use for function?
- Modify a function without editing template
- Problem only while using require_once() within functions.php
- Passing values from a widget to a function within a plugin
- How to filter, restrict and return posts based on custom user meta information
- Add other social networks to TwentyNineteen_SVG_Icons class in child theme?
- What did I do wrong in my functions code, that will not change the “Get New Password” text to “Send It”?
- Replace a menu with widget or a custom template file programmatically
- Override the WordPress core function wp_referer_field
- How to edit the Tags within the image file URLs?
- How would I go about replacing this function in my child theme located in inc/template-tags.php
- Can’t properly set the_title add_filter to show short_URL
- How to add_filter html template to middle of content
- (Woocommerce) Order by price when entering specific category
- How to edit classes in body tag?
- Possible to hook into Media Library preview File column and use a custom image?
- Add back in child theme what the parent theme removed with remove_action
- How to have different site identity logos on each page on Astra Theme [closed]
- How to edit/replace Parent functions.php function in Child Theme to add “Walker” class
- Insert Content Before div#main from the functions.php File
- Add Adsense code between job listings – wp job manager plugin
- remove_action not working, even after changing priority [duplicate]
- Changing the text of Upload/Insert on Posts and Pages Screen
- Any adverse effects of adding apply_filters to a function?
- how can I add filter in specfic field in my website?
- Save_post – Warning: Cannot modify header information
- custom error message for empty username and password using authenticate filter not working
- Plugin function in child theme
- Override parent theme function that is not hooked or in the functions.php file
- Force resize for all video content
- Why functions metaboxes is causing White Screen in Admin [closed]
- get_template_directory_uri pointing to parent theme not child theme
- How to customize the_archive_title()?
- remove empty paragraphs from the_content?
- How to override parent functions in child themes?
- remove_action on after_setup_theme not working from child theme
- Remove Actions/Filters added via Anonymous Functions
- Adding a second email address to a completed order in WooCommerce [closed]
- Child theme – Overriding ‘require_once’ in functions.php
- Set JPEG compression for specific custom image sizes
- Include files in child theme functions file
- Import WordPress XML File from Within Functions.php
- Redeclare a function in a child theme
- Does hooking into the same action multiple times drain memory?
- Add class to menu items of one specific menu (nav_menu_css_class)
- How to override a function when isn’t at functions.php
- Extract image from content and set it as the featured image
- Child theme functions.php do I use php open and close tags?
- Is there a hook or function I can use to display all theme files being used on a current page?
- Issue with get_theme_mod returning a blank value instead of the saved value
- Removing default image size list in Media Box
- Declaring an instance of class included in parent theme from child theme functions.php
- One Child Functions.php for Multiple Child Themes
- How to restrict actions and filters “properly” by conditions
- Add action hook conditionally – only when home.php in use
- Filter the query ONLY for the search results page
- Show modified time if post is actually modified
- why doesnt is_home() work in functions.php
- Removing custom background and header feature in child theme
- opening links in new tab using – add_filter( ‘the_content’, ‘make_clickable’);
- How to create thumbnails for PDF uploads?
- Using add_filter() in Widgets
- How to override function in functions.php of parent theme?
- Customize WordPress Media Manager – Media Window
- Help me to understand wp_header() and wp_footer() functions
- How can I tell if I’m on a login page? [duplicate]
- override parent theme configuration in child functions.php
- How to reduce original image quality on upload?
- Child theme – overriding add_image_size by a child theme [duplicate]
- Is it possible to use a forgot password url filter?
- In WooCommerce I need to modify the thankyou.php page [closed]
- Change the footer text on the login page
- How can I add an extra WooCommerce hook
- Is it possible to override this function/class in a child theme?
- Add body class of category parent
- Why get_header() or get_footer() does not run twice if called in the same php file?
- How to override functions.php in child theme?
- Overriding core functions in child theme
- Wrap gutenberg block ‘div’ in other elements/extra HTML
- Check if page parent has certain template
- Convert hyphen to underscore in permalinks
- Programmatically Add Font-Awesome Icons to Category Widget
- Get password when user registers and save it sha1 into database
- How to override WordPress registration and insert an auto-generated username?
- Function in Child Theme not overriding Parent Theme function [duplicate]