get_template_part()
is including a template file from the active theme directory.
For example:
get_template_part('content')
will include the template content.php
from the theme folder.
When having two parameters, it will search for a template named firstParameter-secondParameter.php
. So:
get_template_part( 'content', get_post_format() );
will include the content-{$post_format}.php
file.
get_post_format() returns one of this defined formats:
aside
chat
gallery
link
image
quote
status
video
audio
or false
. So the file included will be content.php
or content-format.php
Related Posts:
- Single Page WordPress Theme – Using page templates
- Finding Page Template and Displaying Content
- get_template_part vs action hooks in themes
- Grab the first paragraph of each post
- First post of each category
- Echo all category names, apart from one
- how to get the post attachement image in full size?
- Change image size depending on page
- How can I use the WordPress Loop and Pagination in multiple instances but different scenarios throughout my site?
- first excerpt fine, subsequent post excerpts shift to the right instead of displaying vertically [closed]
- List categories of a post hierarchically?
- Local variable name in setup_postdata()
- How get the 10 most viewed pages (not post)
- How to close open divs in post loop
- Why am I getting posts back when I shouldnt
- Meaning of “if ( is_home() && ! is_front_page() )” snippet?
- Should we use get_template_part() in functions files instead of include_once?
- Add a dropdown to theme customizer
- What is the problem if I use CDN in my WordPress parent theme(built using bootstrap)?
- Is it possible to use line break in theme description?
- What is the best book to learn how to make themes for wordpress?
- How to check if post has any tag?
- How do I “unhook” / de-register jQuery so that it’s not called as part of wp_footer();?
- Which is the simplest theme for WordPress to use it as your base?
- “Cheatin’ uh?” error message on multple theme directories
- Adding WordPress colorpicker in widget settings
- A theme that follows all the best practices to learn from?
- get_post() function returns post even if it is trashed
- How to highlight the current page in the nav menu?
- “Display Site Title and Tagline” checkbox not working?
- Setting hero/splash section as a blog post
- Add social icons in a theme through custom admin menu
- file_get_contents Not allowed in Themes?
- How to retrieve an image from a post and display it before excerpt of a post? [duplicate]
- Why is the first query affecting the second query, even after wp_reset_query() and wp_reset_postdata(), but not on the second page?
- How do I remove twentyten without ruining what I did?
- Custom theme not visible in Appearance
- Dequeue a style file which is making website load slow!
- Can’t delete theme
- How to add a second stylesheet to the editor
- qTranslate with my own theme and settings
- paged > max_num_pages won’t throw 404
- Single Page theme [closed]
- Can I have two different theme for two different language?
- Limit Loop to 5 Posts?
- How to show user online status on their posts?
- WP_Comment_Query – Get comments and answers separately
- excerpt() shows different result between remote and localhost(development environment)
- Prefix best practice, should we use framework name or theme name?
- Theme Javascript.php Overwritten Nightly [closed]
- How to add Space between sidebar and footer widget in WordPress theme [closed]
- How can my theme allow users to take advantage of advanced html tags in posts
- Call to undefined function add_menu_page() on theme activation
- Is it acceptable for a WordPress theme to not accept widgets?
- Should all references to a text domain be to my current theme?
- Custom theme: How to call archive-post.php for viewing blog posts
- Simple child theme modification but links are broken
- Making a WordPress theme based on twentyten
- Thesis -style Navigation
- theme style is applied on the dhasboard rather than the website
- Alignment Problem [closed]
- What $handle does WordPress use for a theme’s implicit style.css?
- Create theme for mobile phones and tablets only?
- Unwanted empty line at the beginning of document
- Why is my container argument not working for wp_nav_menu() [closed]
- best practices for updating wordpress theme
- help needed for suit designing tool
- How can I sort my loop based on meta data, using a form?
- How to modify theme content in Thematic?
- Exclude parent categories from the_category() within the loop
- How to update mark-up of a gallery block in a custom theme?
- Host Private Custom Theme
- My wordpress theme name isn’t updating straight away
- How do I make my terms for each product display via foreach loop? (woocommerce)
- WordPress Insert ads after every 5th post
- Why front-page.php doesn’t show content of file instead shows loop
- Customizer API Multi Sections in single Panel
- WordPress theme options checkbox default checked state
- Copying a modified theme from one wordpress site to another wordpress site [closed]
- How can I change this SVG shape that’s generated?
- Adding a second logo next to the main one in header
- (Parent) theme Is Not Showing In Theme Selection Panel and Therefore Breaks Child Theme
- Are paginated comments required for publishing Themes?
- How to show some of category in wordpress
- using themename_the_custom_logo() in template-tags?
- Creating a theme just to deploy a single page
- control posts order by select option
- Custom page template not showing on page creation
- Custom theme vs theme customization?
- Weird ‘theme update’ error [duplicate]
- WordPress two sidebar layout or theme
- Standard Way To Do Custom Work Within A Page?
- Add Dynamic Sidebar to Exisiting WordPress Theme [closed]
- Why does the first loop take arguments from the second loop?
- How can I install my custom-made theme on a wordpress.com blog? [closed]
- WordPress Loop with Custom Post Type for Bootstrap Accordion [closed]
- Is there any reason that other theme elements (such as nav menus) shouldn’t be within the loop?
- .submenu class missing in output from wp_nav_menu
- How to automatically set a Template Page Name next to a page in menu screen such as WooCommerce pages, front page, or posts page in wordpress?
- How do I send out an update for my custom wordpress theme?