You can use has_post_format to check the if the post format equal to some format type.
From the docs
if ( has_post_format('gallery') ) {
// Do something
}
Or use $format = get_post_format() and then do some condition..
$format = get_post_format();
if ( $format == 'gallery' ) {
// Do something
}
If you want to use it outside the loop there is a problem with this method. because it check if the first post is in the format.
So its could return false positive if you are in category page when the first post has the post format too.
For outside the loop you can check for the get_queried_object
$queried_object = get_queried_object();
if($queried_object->taxonomy == 'post_format' && $queried_object->name == 'Gallery') {
// Do something
}
Related Posts:
- Custom Post Type Archive.php
- how do I add a button in each category to display all posts?
- How best to create a variation of an archive template work?
- How To Get the Correct Character length of the Category Archives Page Title
- Override the else part of the index.php loop.
- How can I change archive.php posts display?
- How to set number of posts to display in archive
- Category Archive
- Add custom field to the archive page?
- Loading custom page template via plugin
- Change number of posts to show on Archive page (custom post type)
- Archive template for taxonomy terms
- Pagination problems with multiple custom post type archive pages
- How to make a custom Archive Page
- Custom taxonomy template not working with simple loop. Multiple CPT using the same taxonomy
- WooCommerce Link to Product Category
- Which php file lists all the post of a category
- Display only posts from referred category on date archive page
- Custom template for archive of a custom taxonomy
- CPT: archive-cpt.php VS custom page template
- Double count view in archive.php
- Custom post type and taxonomy permalinks – Structure
- Navigation menus not showing because of custom post type filter
- Rewrite URL for only archive page (custom post type)
- get_terms in a taxonomy template
- Archive slider for CPT
- creating custom archive template within plugin for custom post type using archive_template filter
- Custom Taxonomy Archive BUG
- Not able to see CPT archive template
- How to test pagination? [closed]
- Archive template for custom post type only lists first 10
- Why is the custom taxonomy archive page redirecting me to a single post? [closed]
- One of my pages uses the archive.php template only. Why?
- How can I define a custom archive for childs of a specific category?
- Why is my site using index.php instead of archive?
- Duplicated posts on category page
- Filter posts in category archive page by year using a dropdown
- Custom post type archive page blank
- Custom Taxonomy index/archive hierarchy
- Co-Authors Plugin Displaying Wrong Author
- get_the_term_list – Return links to edit.php instead of link to taxonomy archive template
- Get current title of archive.php
- Which Template Page Should I Use?
- show ALL latest posts with archive.php on example.com/latest
- Pagination doesn’t function properly for archive of a custom post type set as the front page
- Use meta boxes inside an archive page template for Woocommerce
- Archive template combined with post slider and regular posts
- How to integrate single and archive templates for custom post type in any WordPress theme
- Add archive/category results to single post page
- How to get posts by category at /%category%/ url?
- Custom post type permalink uses archive page to display posts
- Do shortcode in template file
- How to create a custom template for custom taxonomy wp-tag-cloud?
- How do I override the default number of items to be listed on an archive.php page? [duplicate]
- Need equivalent of single_term_slug
- Best way for a plugin to define a custom post type archive template?
- How to make different urls for some tags pages
- Links to previous/next month archives
- Custom post archive page not opening 404 page
- How to create archive page to add in menu
- Archive page of CPT’s custom Taxonomy
- Is it possible to set archive.php instead of index.php to display blog?
- Pagination links for custom post type shows correct number of links, but links result in Page not found
- How to overwrite the category template in a plugin
- How do I custom a page that doesn’t exist in the page list?
- I can’t go to the page archive-{post_type}.php
- setting offset to category number in archive page
- Finding the CPT archive template source
- Shortcodes not working in custom page
- ACF Pro Accessing fields on a Custom Post Type
- Show products as posts on archive page
- BuddyPress : how can I call the template WordPress would have chosen (template hierarchy)?
- PageNavi redirects to 404 when used as archive page
- How to Completely Remove Archive Title a.k.a the_archive_title?
- Change Title Based on Taxonomy Filter in archive-{cpt}.php
- How to create a completely functioning separate archive for posts from only 1 or 2 specific categories
- Permalinks custom base to redirect to archive.php
- Iterating over custom post type archive returns incorrect first ID
- Custom taxonomy return 404
- Page 2 has no posts?
- How do I make my archive page look like popular reviewing sites (e.g., Polygon and Gamespot) [closed]
- Display custom post type archive on page.php template
- Get Non-Paginated Index of Post in Paginated Query
- Redirect or Prevent Viewing of Custom Taxonomy’s Archives?
- How to assign custom post template to its custom taxonomy terms
- WordPress Archives Cause Looping
- Page Templates Used in Custom Post Type
- How to display custom post types AND regular posts separately on a shared taxonomy archive?
- Archive posts on showing current page instead of archive
- Displaying categories items among posts
- Use different archive template for plugin
- Archive.php, and post_is_in_descendant_category
- Using post type archive page for taxonomy archive
- URL rewrites af
- WordPress 3.6 – archive.php doesn’t get triggered [closed]
- Pagination not working only on Archive-Name.php using new WP_Query
- How to make posts under custom post type not generate a URL / post
- WordPress CPT archive page display sticky post first and then display the rest of the posts in same Query
- How to create archive child pages with good Yoast SEO meta?
- order archive page by title in wp twenty twenty-four template