Yes, you are using the function wrong. You don’t need to echo the return of get_template_part()
– the template it references will automatically be echo
-ed.
Furthermore, you don’t want to have a leading forward slash (/
) at the start of the first parameter, or the .php
extension, nor the second parameter.
Your function call ends up looking for:
my-child-theme//template-parts/hero.php-hero.php
↑ ↑ ↑
Double slash caused │ Extra -hero from the second parameter.
by leading / in first │
parameter Extra .php
from the first
parameter
Rather, you’d want:
// my-child-theme/template-parts/hero.php
get_template_part( 'template-parts/hero' );
Related Posts:
- How can I load a page template from a plugin?
- Can Page Templates be Applied to Archive and Post Templates?
- Best way to distribute templates and code accross multiple wordpress sites?
- Load php file with jquery in single.php
- Page template compatibility with different themes
- How to include a file using get_template_part() in a plugin?
- Looking for WordPress System Diagrams
- How can I add an option to the Page Template list from a Plugin?
- Overwrite theme file from plugin
- How to add custom content template part for a custom post type on main query using a plugin
- get_template_part from plugin
- How to control output of custom post type without modifying theme?
- Loading custom page template via plugin
- When is it appropriate to put functions on page template vs. functions.php?
- Filter to change the content of 404 page
- How to create custom home page via plugin?
- Templates & CSS – Proper Programming Practice?
- Dynamically override page.php or single.php with custom templates using function
- Is it possible for a plugin to register a page template file?
- Accessing $post variable from template part
- How to properly use a hook to create template for custom product type in a plugin such as Woocommerce? [closed]
- Calling a function from functions.php in custom page/ blog post
- Build dynamic page from cURL (HTML page) response with plugin
- How to check active theme is parent or child wordpress
- Load page template with custom content using a plugin
- How to move style from template file to section?
- How to Add Page Template from Plugin without Losing $this
- WordPress removing data attributes for scheduled post
- Is there a way to loop through a shortcode datasource to create a table?
- Dequeue theme stylesheets but keep widget styling on custom page template
- How to display non-page / post content
- Change template dynamically
- creating custom archive template within plugin for custom post type using archive_template filter
- Is there any way to get all the name or slug of template parts used in a page?
- Where to call wp_enqueue_script in a plugin with custom template?
- Problem with parameters in url and pagination
- Set page template programaticlly in plugin
- How can I pass get_the_author_meta(‘user_email’) through the REST API?
- ORDER BY wp_post custom column name in wp_query
- Register Page Template from Plugin
- how could I load a different template part by page
- Create a free scripts and styles template within a plugin
- How can I turn a custom wordpress page into a product page?
- Plugin-generated pages use Not Found or Pages Archive templates?
- Custom Plugin theme filter
- Plugin templates vs Parent Theme
- How to make “upgrade safe” theme for a plugin?
- What action hook can I use to add a JavaScript to a page post using a theme template that is not including get_header() nor get_footer()?
- Remove sidebar on single page using plugin API
- my basic php code producing unexpected results
- Create page (not the post type) dynamically
- How to create templates for a custom module to show on the front end within my theme?
- Why aren’t some plugin styles loading when I load a template?
- Plugin custom post template; without overriding all posts
- How to output functions from plugin inside theme
- How to use template inside plugin shortcode with variables for big HTML code
- How do I show content from a plugin using the template the site is currently working with?
- How to remove/replace current page template?
- Organize template parts and page templates in folders in regards of template hierarchy
- Conditionally check if page is using template from plugin directory
- Overriding the template files using a plugin for all themes
- How do I use a plugin to swap out the template file for a custom post type?
- Display a custom 404 page without a redirect
- How to save multiple values in custom post type from front end to back end
- Javascript not being loaded only in custom taxonomy template
- Add new header/footer on landing page with plugin
- Change Front page displays settings conditionally when user is online
- Can’t create a blank template
- How can I load Template file from wordpress plugin
- Code to add template to page
- Use a page as a template for a custom post type
- How to set custom homepage via a plugin
- Template file structure , wordpress hook for altering the template
- When to use content-pagename.php?
- Displaying External Data – Not Posts
- Making plugin output customizable
- Use different archive template for plugin
- How to display custom taxonomy and terms using/creating plugin template
- How to check during “pre_get_posts” if WP performing default query for specific custom template?
- Using a Page Template Not in Theme
- Find Any Theme’s page.php File
- WP Job Manager – Show recent jobs as cards
- Help interpreting @wordpress/create-block-tutorial-template usage error
- REST API error in block editor for custom templates
- How to provide page_template path in custom plugin using WordPress
- Generating Multiple Divi Pages from Database
- ‘global’ not working when passing variable from plugin file to template
- Get_Template_Part and Template files in TwentyTwentyFour Block Editor
- plugin content on front-page only. Nowhere else
- How to get current logged-in user details in multisite?
- Check if the current user is author of first comment
- WP Plugin with Upgrade option
- Detect change in site_url and home_url
- Reporting errors in a shortcode plugin
- How can I control if post updated
- Does WordPress default CSS have Grids?
- Gravity Forms Anchor only on Front Page?
- How to get the current category with custom posts
- shortcode tags not working in do_shortcode
- How to show parents of current page category, excluding the category?