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?
- Customizer: get_preview_url() inside customize_save_after hook
- Valid SQL query not returning results
- How to track a users last visited page?
- get_header action not working
- In a Gallery with limited image posts, how do I not limit images on single post?
- Shortcodes do not work in own template
- Adding Bootstrap to WordPress TwentySixteen Theme
- Unable to change the priority with ‘remove_action’ and ‘add_action’ in child theme
- LESS not working in WordPress [closed]
- StoreFront WordPress theme: How can i create a new Home page with Custom design same as template [closed]
- How do I include a partial from a directory below a wordpress theme directory?
- Is there a way to switch to another theme?
- A post with a clear:both in its css destroy the theme design, and the sidebar is moved to the bottom
- How does the loop know which post to view?
- New to WordPress – Read the Codex, Other Docs; Still Confused
- How add built-in textarea in theme development?
- Create theme for mobile phones and tablets only?
- Is there a way to retrieve the calling template part?
- Unwanted empty line at the beginning of document
- How to add custom page elements to the WYSIWYG editor?
- Why is my container argument not working for wp_nav_menu() [closed]
- Remove h1 from 2015 theme
- Never actually adding the action? Or do I have to call the action?
- WordPress pulling in random page themes
- best practices for updating wordpress theme
- Retrieve WordPress’ the_content() with jQuery
- Exclude subcategory from wp_query
- Style first 3 posts differently with WP_Query [duplicate]
- Why I obtain different visualization when I run the website on my local machine and on remote server?
- Some doubts about WordPress handle the horizontal main menu visualization
- WP_Query not getting all posts, just tagged posts
- Filter didn’t work on content class (hybrid_post_attributes)
- Can’t change theme name
- How to hide custom sidebar on mobile
- How to use the _S framework
- When trying to set title, not sure how to edit it for different pages
- How to remove permalinks links presents in each page of my site?
- Is it possible to have a Theme with built-in physical page files?
- Pagination and multiple loops
- Post archives link yields a 404 Not Found
- Change Image Sizes for Mobile Theme
- Recommended sidebar / content widths
- Theme Checker Text Domain
- Converting a theme to a child theme in a network
- HTTP Error when uploading images over specific dimensions
- Get video from the post on homepage
- Why is the `if else` not working?
- help needed for suit designing tool
- static front page ONLY for certain themes?
- showing all recent posts in theme
- How to add cropped custom header image?
- Is there a way to serve different resolution images to different devices?
- What is the difference between Twenty eleven & roots framework?
- Open portfolio image in light box
- iPad WordPress theme?
- Let visitors show/hide a type of content
- custom Background not showing after upgrade?
- Custom fields in post later used in loop
- Rolling your own WordPress Themes
- WordPress Themes Directory: Template which hits the standards?
- Best practice for implementing a blog page / section in wp_menu_nav()
- Exclude function from homepage only?
- How can I sort my loop based on meta data, using a form?
- How to modify theme content in Thematic?
- How to make a function occurs for one time?
- Exclude parent categories from the_category() within the loop
- How do I restructure the comment HTML layout?
- how to add a badge on product based on filter?
- How to change a local wordpress installation xml export file urls? and change them to what if you don’t have a live website?
- get_the_terms() returning wrong results inside of loop
- Any way to change/add to the theme name dynamically?
- Trying to link to a php template file but its blank
- Is there a list of default generated Gutenberg block CSS? Unable to align video blocks
- Let user to upload multiple time
- How to copy page/post from one theme to another?
- Not sure how to debug this npm install error. This is a wordpress theme that comes with a built-in gulp/webpack task automation [closed]
- How to update mark-up of a gallery block in a custom theme?
- PHP Parse error: syntax error, unexpected ‘endwhile’ (T_ENDWHILE), expecting elseif (T_ELSEIF) or else (T_ELSE) or endif (T_ENDIF) on line 124
- Show only pages you are author of
- How to change listing type permlink?
- Adding popup support to the theme
- Host Private Custom Theme
- Theme author.php transfer
- how to create/register menu items that can be added to menus later