First of all note that get_template_part
internally uses locate_template
, so your feeling that the latter is slower is wrong.
If you look at the code, get_template_part
is little more than a wrapper for locate_template
, so if one work and the other not, there are 2 possibilities:
- you are using
get_template_part
wrong - there’s some hook on
"get_template_part_{$slug}"
action that prevent it works
However, if locate_template
works, use it: it’s not slower, to be honest it can be pretty faster if there are functions hooked on "get_template_part_{$slug}"
that slow down execution.
Related Posts:
- Is there any way to use get_template_part() with folders?
- Is it possible to override the result of get_template_part()?
- Templates & CSS – Proper Programming Practice?
- TwentyTen: Overloading template.php files vs. get_template_part
- Passing variables to template parts
- How to move style from template file to section?
- Unable to include a template
- Where is the template for the ‘standard’ format of a post in the theme twentythirteen?
- Valid HTML in Template Part
- Remove portion of header code from home page only
- Use a separate template for the home page only
- How to create new template page and template-parts in wordpress theme [closed]
- Including template pages within another template?
- Organize template parts and page templates in folders in regards of template hierarchy
- How to get all template files used for rendering a single post/page?
- get_template_part for template in subdirectory not working
- Display a custom 404 page without a redirect
- How can I show contents of a template part inside of another page?
- When to use content-pagename.php?
- Is it possible to call a template file inside wysiwyg editor? And how?
- Adding Page Attributes Metabox and Page Templates to the Posts Edit Page?
- Print WordPress template filename(s) for debugging
- How to add custom content template part for a custom post type on main query using a plugin
- Change the name of the ‘Default Template’
- Echoing Elementor page content in template, but it doesn’t get styles and some widgets are missing
- How can I modify the default reset (lost) password email text?
- Template files missing after moving site
- Create Page that uses specific template
- Sharing templates with the JSON API?
- index.php template is used instead of blog page
- Prevent private post 404
- NextGen Gallery template cache [closed]
- Set template based on query in URL
- Template tags for Buddypress
- ACF image field to WordPress featured image
- Child theme template file will not load
- get_template_part returns NULL
- ACF – Theming Flexible Content
- How to delete read more span on single post view?
- WordPress editable template fields
- Conditionally display different images before the content in a page template
- One of my pages uses the archive.php template only. Why?
- Why are 404s not triggering my 404.php template?
- Is there a way to create a block template that is not limited to a post type?
- How to show “teaser” posts on blog / archive pages, otherwise full posts
- link to non-category page routed to category template
- Can’t format content of Rich Text Editor in Template
- get_file_data to read data for Custom Template File?
- Footer.php not showing?
- How to publish a Page and Posts using single template
- lost css when overriding themes templates
- What is the best practice to style archive page 2,3,etc differently than archive.php?
- How to create a post template with two sidebars
- ACF costum date format [closed]
- != and !== both not always working? [closed]
- Page template for a site from network
- WordPress 3.3.1 single post template
- Conditional to determine if search.php page is the current template
- Prevent 404 and serve custom template for custom URL
- Page Templates not using functions.php
- Add stylesheet per layout
- Get template part with CPT and Custom Taxonomy conditionals
- use a custom page to display search results
- When a user registers, create a page from an existing template with their username as the page name
- How to add description over forum list on bbpress root page
- two active templates for one post
- Where is the code for “Front Page Template”?
- Help Understanding Template Hierarchy
- what is template-name.php
- templates with page teasers Or Featured Items
- If Child or Grandchild of Page
- Page template not registering on theme
- Is it possible to create custom links inside a template?
- How do I custom a page that doesn’t exist in the page list?
- Uncaught Error: Call to undefined function twentytwenty_the_post_meta()
- Timber + MtHaml, or any other HAML-like HTML shorthand
- small problem in the article ()
- Unable to access wordpress page
- How can I make custom page templates work on child theme?
- Archive only for /year/month, not terms
- Why default template does not show?
- Why does the blog page not take the page template selected?
- Custom Taxonomy Theme file not routing correctly
- Why would adding a template file to a child theme cause an error in template-loader.php?
- How can I make is_page_template() workable in child theme?
- How can I add some blocks to template without changing template file?
- Creating a popup
- Category template not displaying all post formats
- Mysterious template change after database import/export
- Is there a way to share a template/markup with the JSON API so that it doesn’t need to be declared both in PHP and in JS?
- Styling own template
- WordPress sites translate dynamically generated Homepages
- changes to templates not showing on server
- Why is this page using the homepage template and not the one it should?
- Single template will not show sidebar/bottom-nav and footer
- Problem with permalink structure for WordPress custom post_type archive template
- pass dynamic value to page to pull in categorised post cards
- How to limit block activity (insertion/deletion) to inside of a Block Template on the Admin Screen?
- How to change post template
- Unload templates; disable parent Template Parts using only “theme.json”