get_template_part()
will work the same no matter where or how deep you are within your theme. It always includes relative to the theme (or child theme) root.
So if you call the following from anywhere:
get_template_part( 'content', 'job-listing' );
… it will try to load (in order):
child-theme/content-job-listing.php
parent-theme/content-job-listing.php
child-theme/content.php
parent-theme/content.php
To load parts that are in a subdirectory of your theme, just use the path in the first argument:
get_template_part( 'path/to/file', 'optional-slug' );
Related Posts:
- Passing variables through locate_template
- How to use get_template_part()?
- Is there a variable for a template parts name?
- How to make get_template_part always check child theme first?
- Check if partial file is called from within header.php or footer.php
- Too many get_template_parts?
- Pass a variable to get_template_part
- get_template_part inside get_template_part?
- Getting the chosen template when iterating through pages
- Possible to use pagename inside get_template_part?
- Why would include(locate_template) work but not get_template_part()?
- How does get_template_part() work inside a loop?
- Is there a tirck in the get_xxxx function in the general_template.php file?
- Problem with using get_template_part() in footer
- how to remove get_template_part from a plugin? [closed]
- get_template_part() based on get_post_type() for a custom post type instead of get_post_format()
- Using get_template_part to retrieve a template file based on current post type
- add a hook with get_template_part()
- ä/ü/… are not displayed when including via get_template_part()
- Change the file path on get_template_part via plugin
- How to limit the number of Related Posts?
- get_template_part – how to find html file which is being render
- Get_Template_Part And Two Global WP_Query On Frontpage
- The use of get_template_part() returns ‘invalid argument’ loading options
- Passing a variable from the archive page to the default template
- For which reasons can get_template_part’s $args fail to work? (WP 5.8.1 – PHP 7.4.23)
- Can I set a global base path for get_template_part?
- how to use a different template (index.php) in wordpress
- What are the benefits of using get_template_part()?
- Include template file from plugin to theme
- get_template_part doesn’t output all data
- Passing a variable to get_template_part
- Is there any way to use get_template_part() with folders?
- get_template_part vs action hooks in themes
- When is get_template_part() preferable to simply using the template.php files?
- How to add custom content template part for a custom post type on main query using a plugin
- Combining shortcode and get_template_part
- Is it safe/recommended to use wp_enqueue_script function outside the functions.php file?
- get_template_part execute with ajax
- Get template part based on custom taxonomy term
- WP_Query on custom post type not displaying, multiple loops & get_template_part
- TwentyTen: Overloading template.php files vs. get_template_part
- Template tags vs get_template_part() vs functions.php
- Template part vs Sidebar (differences)
- How to move style from template file to section?
- get_template_part in admin
- Finding Page Template and Displaying Content
- ACF Relationship + WP Template Parts
- Does get_template_part pull data once in a loop?
- Post Format single-loop.php using get_template_part
- Filter get_template_part() $args array
- Is there any way to get all the name or slug of template parts used in a page?
- get_template_part for each level of taxonomy term
- What is the best way to organize template parts?
- Get template part using a custom taxonomy term
- Get_template_part inside a folder
- add active class based on permalink and url
- Overriding of the template for the Attachment “thumbnails” in the Media Grid isn’t working
- Styles and scripts inside template part
- How to show “teaser” posts on blog / archive pages, otherwise full posts
- Modify foreach loop for social sharing links?
- get_template_part based upon post’s category
- Loading template parts conditionally in Customizer
- How do I display an image before the first post of the loop when I’m using get_template_part?
- Tag page only display 10 posts
- Remove portion of header code from home page only
- Use a separate template for the home page only
- How do I get standard posts to open up in their own template when using get_template_part()?
- get_template_directory_uri() not working
- How to reuse get_template_part() containing a simple loop to work with AJAX correctly?
- How to use template inside plugin shortcode with variables for big HTML code
- Both the require and add_template_part function are not including the file
- Displaying a custom post type using get_template_part into a specific layout
- get_template_directory() returns wrong address on VPS
- Get template part with CPT and Custom Taxonomy conditionals
- How can have a conditional template tag based on the main loop within a secondary loop with new WP_Query(), using get_template_part()
- Use of IF statement in Header file
- Organize template parts and page templates in folders in regards of template hierarchy
- Custom fields in post later used in loop
- Exclude function from homepage only?
- How to get all template files used for rendering a single post/page?
- how to replace h1 entry title with h2 in category pages only
- Custom wp_query inside a conditional stament inside a template part doesn’t work: why?
- Contain multiple page templates in one PHP custom template file in WordPress?
- Adding a second loop breaks everything
- do_action doesn’t trigger if it’s in a template that gets loaded via REST endpoint
- Shortcode and get_template_part
- How can I show contents of a template part inside of another page?
- Call get_template_part() custom permalink
- Continue loop after $queryObject
- Use another theme template in my theme
- When using shortcode, content stops generating after the_content
- Using require_once for parent-directory not working but is working in sub-directories
- How to unregister sidebar for template_part?
- Is it possible to call a template file inside wysiwyg editor? And how?
- Re-using single CPT code with get_template_part?
- get_template_part() to render single page Theme
- strange parse error when including a loop template within another template
- Print post data inside loop using theme content template
- First post outside of loop, homepage only?