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?
- Date not working correctly
- How to add product in woocommerce with php code [closed]
- PHP unit testing WordPress?
- List of all theme customizer control types?
- How to add date range in woocommerce with code
- Creating custom Woocommerce attribute taxonomies from a plugin
- WooCommerce: How to display item meta data in email confirmation using woocommerce_order_item_meta_end
- How to get the original price of the product in woocommerce?
- The best way to customize “nav-menu-template.php” to add if the ‘link_before’ is “checkbox”
- How to Remove a Filter from the Admin List Table?
- Multiple do_shortcode($content) within one shortcode
- Woocommerce, recognize the loop of related products
- Remove commas from WooCommerce checkout addresses fields
- WooCommerce Link to Product Category
- Advanced Custom Fields Image Field returning ID instead of URL [closed]
- Widgets not showing in my custom theme
- Output a WooCommerce product custom field in WooCommerce using get_post_meta()
- Append a term to WooCommerce product existing product category terms
- using woocommerce_template_single_add_to_cart in shop-loop – javascript issues [closed]
- Can an array be used as a meta_query value?
- What is the fastest way to load PHP functions that are only used in one theme template?
- Writing scripts using WordPress / WooCommerce classes?
- ACF check if variable has http, if else return string
- How do I access the media settings
- How to make custom total price reactive in navigation
- Change description on specific WooCommerce product status change
- Can’t load WP function into external function
- Woocommerce – Filter Variable Products by Variation Attributes and Variations Regular Price
- How to add a second ‘place order’ button in WooCommerce [closed]
- Implement toggle switch for theme options in settings API
- Woocommerce redirect thankyou page based on product ID doesn’t empty Cart
- tracking number field in Woocommerce order [closed]
- WooCommerce Related Products by Attribute
- Image as Sales Badge
- How can i upload images in an admin page?
- Wp-login appears White Screen, Error: Cannot modify header information
- ACF: how do I get the fields and its values of a specific group?
- Modify HTML structure of fields in woocommerce checkout form
- Need Help Fixing My Iframes [closed]
- Add a product to checkout via form
- 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
- Remove the first 5 characters of the_title and orderby that
- How can I get the values of my WordPress $wpdb query in Jquery?
- Trouble checking if custom woocommerce checkout field is empty or not
- My new button is in the wrong place
- Compare the old get_theme_mod($name) to the new get_theme_mod($name) return value
- Why in my theme I can’t see all the statics content under the posts?
- Double Curly Brackets in Php
- Seo Friendly Filter URLs
- WooCommerce – Moving Product Price to the Left of Add to Cart Button [closed]
- Have Woocommerce show product price if id, when not logged in
- Removed jQuery script from header.php , any problems?
- How to correctly load a different version of main menu based on the user language in WordPress? Is it a good solution?
- Need help for some PHP code
- How do you get the current post taxonomy so I can get the current post taxonomy? into a variable to THEN loop through all post with that taxonomy.,
- how to replace h1 entry title with h2 in category pages only
- ACF: Display Google Map in frontend issues
- Display post date also if the date it’s the same for each post
- How to get content on a blank basket/cart page in a custom theme with woocommerce
- Submit remote form to wordpress REST API and save data to custom post type
- Add a custom link to each image in WordPress gallery
- Woocommerce – if selected attribute term equals
- split 1 cart item into instock and back ordered
- register dependency css and js inside a plugin class
- Collapsible menu on post sidebar only expands and does not collapse
- Adding a widget under an ‘Add to Cart’ button through a PHP snippet
- Hide price excluding tax when price is empty
- How to get php file based on URL in WordPress
- Woocommerce variation with radio button + price
- Adding code to the function file
- Using is home to get content [closed]
- How to create a container in php then customise it in CSS
- Find owner of coupon
- Add default block css when the block has been added with php?
- Advanced Custom Fields – How do I get field values of a group within a group field type
- Retrive the value of the Active variation of the product and then link it to the “read more” to dynamically change
- Advanced Custom Fields Auto Populating Field Values For Nested Repeater FIelds
- create custom post type and populate custom fields using php
- WordPress per ACF – permalink is not working
- Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english