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
- blog archive page styled from default template instead of from custom template
- Custom Post Type Settings page, choose page to display archive
- How To Create A Paginated List Of All Categories On My Site?
- How to get the custom post type from an archive page?
- 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
- Display page of custom posts?
- Landing in 404 Page on Navigating to Custom Taxonomy Archive
- 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
- How do I change the sql query for wp_get_archive()
- Last post is not showing up
- Custom template for archive of a custom taxonomy
- WordPress custom post type archive with description
- CPT: archive-cpt.php VS custom page template
- Custom query in archive.php with pagination nightmare
- 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
- How To Create A Custom Taxonomy 404 Page
- 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
- Change archive page template using pre_get_post
- WordPress subcategories return 404 in custom template
- Custom post type is showing custom home page, not archive page
- 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?
- Isotope Filtering with Bootstrap Tabs – Custom Post Type Query Loop in each Tab (Have to click twice to filter)
- How can I define a custom archive for childs of a specific category?
- Restoring default article pagination on archives – Removing custom limits
- Why is my site using index.php instead of archive?
- How can I use $wp_query->tax_query as tax_query parameter for a new WP_Query instatiation?
- Duplicated posts on category page
- Filter posts in category archive page by year using a dropdown
- Only one post is showing on category page, why?
- Custom post type archive page blank
- How to override p2 breathe theme plugin in content template file?
- 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
- Increase 10 post limit per page
- Custom Post Type Archive template page not found
- My archive-posttype.php template is not loading
- Custom Post Archive is not working
- Get current title of archive.php
- How to list articles by year based on url?
- WordPress override archive page template using a plugin
- archive_template override when no posts exist
- Which Template Page Should I Use?
- show ALL latest posts with archive.php on example.com/latest
- Display custom post types in wp_list_pages
- Pagination doesn’t function properly for archive of a custom post type set as the front page
- How to customize taxonomy archive template files for subterms?
- 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
- Is it possible to have a template that works on multiple categories where the link address contains the specific category?
- How to get posts by category at /%category%/ url?
- Custom post type permalink uses archive page to display posts
- Image loading function not working on archive.php template
- How to add html code at the bottom of the post in archive page?
- Taxonomy template page not working
- Do shortcode in template file
- How to get the Custom Post Type Archive inside a folder
- CPT with its own category and tag url
- Custom Post Type Archive template not being called
- Limiting the Archive page to posts posted by particular author
- Can’t replace the default sidebar with a custom sidebar on Custom Post Type in Genesis
- How to create a custom template for custom taxonomy wp-tag-cloud?
- Highlight archive link on single.php
- Ascending order of yearly archives [closed]
- How to Fix an Archive.php That Displays All Posts?
- How do I override the default number of items to be listed on an archive.php page? [duplicate]
- How do I create an alphabetically organized glossary of links?
- 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
- Is possible register two archive pages for single custom post type?
- Links to previous/next month archives