You cannot include
template files via URL, which is what get_template_directory_uri()
returns. You need to use the server file path, which you get get with get_theme_file_path()
:
$heroslider = get_theme_file_path( 'template-parts/hero-slider.php' );
echo $heroslider;
include_once( $heroslider );
However, if you’re including templates (rather than files with function/class definitions), you should use get_template_part()
to get the correct path and include it in one go (just leave out the file extension):
get_template_part( 'template-parts/hero-slider' );
Related Posts:
- How to check if woocommerce is activated in theme
- Conditionally loading JavaScript based on the Advanced Custom Fields in the post
- Hide a menu-item and its submenus and display a ‘Log in’ link if the user is logged out
- The values of custom fields are not available functions.php
- My Own layout in WooCommerce pages [closed]
- write custom woocommerce templates and forms
- Redirect to another page using contact form 7? [closed]
- How to remove woocommerce_breadcrumb() from do_action( ‘woocommerce_before_main_content’ ); [closed]
- Set ACF on order during checkout
- Exclude category from woocommerce product category list
- Get field value and use as variable in php
- Place product field value as variable in php
- ACF under category name in shop page [closed]
- WooCommerce Custom Tab with ACF Repeater Field
- Woocommerce variable products are being added to the card on the homepage (ajax)
- Order woo products, but first products must be with acf fields
- Show button in header when product custom field is not empty
- Woocommerce Convert existing order to the cart
- How to get ACF field to show up on all posts on front end?
- Phone number custom field and woocommerce updating issue noticed
- How to capture number input from wordpress form into acf field in woocommerce
- Date not working correctly
- Set the checkbox as checked by default at options page
- Automatically remove a canceled order in Woocommerce
- Using Advanced Custom Fields to create a per page slider
- Create another “Display Site Title and Tagline” checkbox, “Header Text Color” setting and control
- Add child pages of parent to navbar PHP
- How can I create a list of page titles from custom meta values?
- Load a page into a div with Ajax
- Call global variable array() in woocommerce child/template
- Custom theme: Alternatives to long list of ‘include’ in functions.php
- Remove price from Woocommerce variable product dropdown menu
- Theme Options Page – User Updates Logo
- Converting HTML Template to WordPress Theme
- How to use my style.css file outside of wordpress subdomain?
- Display PHP within HTML values
- Adding nofollow to a PHP generated Nav
- How to show part of the_content?
- Wp-login appears White Screen, Error: Cannot modify header information
- How to remove the cufon script from Dzonia Lite theme [closed]
- get_the_tags() not iterating through for/while loop, but will with foreach
- Hide categories that are not used in the post type
- Automated Cart Update With Alert Box Each Time
- Two Different Links for Same Product – WooCommerce [closed]
- Issue adding sub category programmatically
- WooCommerce/WordPress: how hide entire table form after submit (Admin Dashboard)?
- ACF: how do I get the fields and its values of a specific group?
- How do I add custom bulk actions to multiple custom post types?
- Add_action not working in required file of functions.php
- How to set up VS Code for WP plugin/theme development in 2021? [closed]
- dividing sub-categories by parent category – WordPress
- Show prices with tax in Woocommerce Mini Cart [closed]
- Why do WP_Query results change after updating unrelated Advanced Custom Fields (ACF)?
- Woocommerce product variation backorder
- Status 400 for AJAX POST Request with admin-ajax.php
- Problem with custom plugin using AJAX to pull info from php file
- Saving an array of dynamic repeater data as post_meta
- adding custom user input fields in WordPress admin dashboard gives error The link you followed has expired. Please try again
- Woocommerce hook run after an Order been created through REST API
- How can I apply_filters from inside a function?
- Get and insert order email address to the PHP template inside HTML text
- what is the best practice to add new field to an api route
- Modify HTML structure of fields in woocommerce checkout form
- Grab posts by multiple categories
- Pass Category Name, Description and Photo into variables to pass to jQuery
- Can’t access variable outside for loop
- I have a problem in the order of enqueues while enqueuing stylesheets and scripts for a specific page in my function.php
- add custom link to wordpress media gallery modal
- Auto-update products after they were published – Woocommerce
- How to VAR_DUMP a $variable during checkout process (Is my product meta callable?)
- Reload part of checkout on changed shipping method
- How to get all shipping rates and costs without session in woocommerce?
- Display a specific category of products in shop page and disable code for specific actions
- If no products are on sale – hide ID or class
- Woocommerce related product text
- Woocommerce api: create product with images – bad request
- Trying to build simple deposit code that hooks into woocommerce
- Need Help Fixing My Iframes [closed]
- WooCommerce Webhooks not firing because of error in wp-includes/meta.php
- Different Minimum Order Amounts based on Shipping Zone [closed]
- Output ACF repeater on frontend user’s profile page (created with Ultimate Member) [closed]
- do search in two site and show the result in first site
- Woocommerce: hook action/filter I could use to add variation id and price with each attribute opt on WooCommerce Rest api
- Add a product to checkout via form
- Avoid parallax images hardcoding
- Improve page speed loading using CDN and async or defer attribute
- Trying to place a custom field after the total section in the checkout page in woocommerce
- WordPress default Search function inconsistent in WooCommerce Product Titles
- Which field should I edit to make the checkbox marked by default?
- Displaying Woocommerce Product Category in WordPress
- Remove the first 5 characters of the_title and orderby that
- Is it possible to intercept all ajax requests and get the parameters and the returns?
- WooCommerce: How can I get orders with a custom ID in order meta data object?
- Unread Repeater field IMG alt not working
- Unable to write multiple values back to ACF user field – PHP
- wordpress + woocommerce display product with additional information [closed]
- how to fix error “called incorrectly, should not be accessed directly”?
- populate form fields in a loop with ajax
- Function works when I don’t login to WordPress but when I login then it doesn’t work
- Error in custom php function doesn’t exist