You can utilize the WordPress function get_template_part();
Create several template files in your theme directory called content-POST_FORMAT_TYPE.php – Example: content-gallery.php and content-chat.php
if(has_post_format('gallery'))
get_template_part('content', 'gallery');
elseif(has_post_format('chat')
get_template_part('content', 'chat');
else
the_content();
This approach makes your code blocks reusable in multiple templates. Hope this helps you out.
Related Posts:
- Allow HTML in excerpt
- Only get_posts of certain post formats
- static variable loop not working in WordPress
- How to return the_excerpt (without echo)?
- Limit the Excerpt field in WP-Admin in words
- Limit the_excerpt with max of x characters
- Remove at the beginning of the_excerpt() with str_replace
- Automatic Excerpt Not Working
- Trim first 2 words of the exceprt
- How does WP detect format type (and can I make use of this)?
- Extremely slow pageload for long post when using the_content?
- How to change / delete product short description in Woocommerce
- Why does running get_the_excerpt() when generating JSON file take 28 seconds vs. 599 milliseconds without it?
- Excerpt unwanted text “”
- Word Count Function Preventing Permalink Editing
- Custom excerpt function re-factoring
- How to Display a Single Post Excerpt
- How to remove the excerpt in the Dzonia Lite theme
- How to filter posts by post format “standard” from wp-json api?
- Get first URL from post content
- How do I Add HTML to the_excerpt() & the_content() Output?
- How do I use this PHP library to access OpenGraph data in a child theme?
- WordPress add post format support not working
- Mass update excerpt
- How to put “Read more” link in Custom Excerpt inside p tag?
- Error when adding excerpt to the content through functions.php
- trigger html cleanup for all posts
- HTML tags not showing in excerpt
- Query Pages and post excerpts dynamically
- My custom get_the_excerpt() can’t get excerpt by ID
- Adding Meta Tags to a Post using its Tags, Excerpt and content
- Using the_excerpt() on a page
- How to show an entire post content and not also the excerpt?
- stripping tags from excerpt in WordPress is not working
- Automatic excerpt is not shown with the_excerpt() command
- Remove   from the_excerpt
- Shortcodes showing in excerpt despite using strip_shortcodes
- How to remove the space before the ellipsis in excerpt?
- Need help removing […] after excerpt
- Display the video of a post_format Video
- Post class only applying to first excerpt; why?
- Assign Custom classes to every Excerpt
- Wrap posts p tags in div
- Conditional for Post Format
- Problem in replacing the_content with the_excerpt()
- Find and print first entry from WordPress post in custom excerpt?
- Cannot figure out how to add a read more link to a manual excerpt. Please help
- Trying to modify content.php
- How to trim content AND retain HTML?
- How to apply filter
- Add point on excerpt post
- Setting ‘post_format’
- Archive page if else not working for post_excerpt and post_content
- How can I add WordPress Audio Player as featured audio in Audio Blog Posts?
- Creating a function that sanitizes the custom metabox excerpt
- Custom single.php files for different post formats
- How can I add more code to this?
- Merging two excerpt functions to work with conditions
- I can’t seem to get excerpts showing inside get_pages and don’t know why?
- Excerpt all post content Content Same Size without word cutting off
- Remove post image caption from post_excerpt();
- generate excerpt from the part of big text dump that contains keyword
- Strip and print only the numbers found in current’s post excerpt (even if they are without space)
- I have issue with decoding json ex. ‘{“a”:”b”}’
- Detecting if parent page has gallery
- Skip foreach loop
- Displaying posts based on category
- Prev/Next Links Broken on Static Front Page Pagination
- Pagination broken on is_front_page()
- Changing the color scheme based on the url visited
- Why is an array created in a function hooked to customize register populated when customizer is loaded but not when the front-end is loaded?
- Mixing variables into an array when inserting values
- Don’t show certain div on front page?
- Could use some help with Shortcodes
- How to integrate noimage picture in this code
- Javascript not loading on certain page
- Location of core code for database connection and get_header
- Deleting Certain terms from appearing on the front end as links
- get comment data using comment id
- meta box not display data input in the textarea
- Clickable image link sends people to wrong URL
- wpdb prepare insert table doesn’t work
- Should I use WordPress to skin a database website?
- php include not working in custom page
- How to modify the default feed via a function
- How do I display offsite database info on my wordpress site?
- Styling the second sidebar
- first instantiated SimplePie object cosumes 5mb?
- Adding a line of text to php code
- If ‘editor’ is empty, then
- Different Subdomain changes page content
- Theme not calling Jquery properly
- customize wordpress database error page
- Removing the comment function within wordpress
- Creating Database Table vs. Adding MetaData to Post & User
- Post’s ID pattern?
- Countdown to date function?
- Include text in echoed hyperlink
- How to put a form with php code into a variable or shortcode?
- Utilize Function in Child Theme / Template File