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 determine if WP_DEBUG is enabled? [duplicate]
- Get author full name
- How to export/import theme customizer settings?
- Is it possible to get a theme customizer setting from wp.customize using jquery?
- One button to change all settings in theme customizer?
- How to remove “out of stock” variation options from size dropdown in woocommerce?
- How to use copy() function and paste file in /wp-content/themes directory
- How can I add a class to a single menu item?
- Get WooCommerce shipping methods programmatically
- Add a custom text field to WooCommerce admin product data “Variations”
- Translating add to cart woocommerce button [closed]
- I think emoji are killing my WordPress site… How can I debug?
- Am I not understanding plugins?
- Looking for most performant way to execute several similar WP queries within shortcodes
- Help with some php math in WordPress
- max_input_vars: how many am I using?
- Trouble With Conditional Logic in PHP
- How do I display a user’s previous orders as a select box option on a product?
- combine Code 1 with Code 2
- Multiple WordPress Menus that will only display all pages
- Custom theme: Alternatives to long list of ‘include’ in functions.php
- 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]
- WooCommerce/WordPress: how hide entire table form after submit (Admin Dashboard)?
- Show prices with tax in Woocommerce Mini Cart [closed]
- Woocommerce related product text
- Is it possible to intercept all ajax requests and get the parameters and the returns?
- How to make products with no cost in WooCommerce
- Menu jumping when calling it via PHP
- Is there a way to conditionally check whether a WordPress post title is empty?
- Advanced Custom Fields – display label and value only if value entered
- Use WordPress function in php file
- Why in my theme I can’t see all the statics content under the posts?
- Add product to cart for user – WC()->cart->add_to_cart [closed]
- Double Curly Brackets in Php
- Seo Friendly Filter URLs
- Display attribute on shop page after the title
- WooCommerce – Moving Product Price to the Left of Add to Cart Button [closed]
- WordPress WP_Query without query GET parameters
- Where to copy woocommerce files to in my custom theme to avoid editing the core plugin?
- 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?
- Trying to change featured image from 180×180 to full width on home page
- Remove the Tag from wp_nav_menu
- 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
- Run a sql (update) after 12 hours after the user login. Woocommerce users
- Problem with displaying CSS Stylesheets – Am I adding them correctly in my wordpress child theme?
- Use Search Term in html link and redirect
- 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
- How to import woocommerce custom fields data into another site?
- 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
- Javascript Tab Gallery with Advanced Custom Fields
- Collapsible menu on post sidebar only expands and does not collapse
- Adding a widget under an ‘Add to Cart’ button through a PHP snippet
- Generate a radius search of custom post type locations
- Hide price excluding tax when price is empty
- Is there a reason why my wordpress PHP page isn’t loading into my PHP template
- How to get php file based on URL in WordPress
- Woocommerce variation with radio button + price
- I want different post-thumbnail size depending on media size
- ACF loop and php formatting
- Custom field within shortcode
- Adding code to the function file
- ACF allow zero as a value
- Using is home to get content [closed]
- How I can give a php page a style from my theme
- WooCommerce – Show ‘Sales’ badge on variable products where only some variations have sales price [closed]
- How to create a container in php then customise it in CSS
- WordPress 6.1.1 UTF8 Slug Limit Increase
- How to add SKU and remove product title from WooCommerce url?
- Product Search in search.php
- using custom pages for myaccount in woocommerce