Today I am going to write about post formats in WordPress. First what is post format? Post format is piece of meta information that can be used by a theme to customize its presentation of a post. WordPress support 9 type of post formats:
Why post formats are important and how to add it in theme?
By using post formats you can make your theme attractive like you can use a small different icon for every different post, you can use different color for post for different post formats..there are many way to use post formats for theme to make theme attractive.
Now you can use/add this post format in your theme. So if you want to add post format in your theme then what you should do? Open functions.php and add below line anywhere in functions.php file :
add_theme_support( 'post-formats', array( 'link', 'video', 'gallery' ) );
Now go to add new posts/edit posts and you will be able to see post formats at right side.
Now you can see Standard post format also, you were thinking that you didn’t add any post format like this also I didn’t mention this type of post format before, So where it comes from? When writing or editing a Post, If you have a post which don’t require any post format then Standard is used to designate as no Post Format. Also if a format is specified that is invalid then standard (no format) will be used.
Now you added post format now you are thinking how we can get that post format for posts while showing posts on site? Ok, So here is the function to get post format for every post.
<?php $which_format = get_post_format( $post_id ); ?>
You can use this line of code to get post format. If you are using this function in while loop then no need of mention $post_id, it will automatically take $post_id if it is used in loop. If you are using outside of loop, then you must have use/pass $post_id to this function in order to achieve post format for that post.
I hope this article helps you.If you really like this article tweet about it or share it on Facebook or make comment.
Among the many digital tools that are being used with…
This question is most searched question in google. It is…
When you are using WPML in wordpress at that time…
Method for linking pages that aren't in a Site Menu…
Manier times we come across requirement like fetching/getting content from…
- Artificial Intelligence
- Augmented Reality
- Digital Marketing
- Ecommerce Solutions
- Ecommerce Web Design
- Email Template Design
- mobile app design
- Mobile App Development
- Static Website Design
- UI/UX Design
- Virtual Reality
- Web Development
- Web Scraping
- Website Design
- Website Redesign
- WordPress Customization
- WordPress Plugin
- Zen Cart
Let's Discuss a Project
Please share your unique idea or project requirement with us, our business concern person will get back to you with further details.