Conditional Tags are a boolean data type that can be used in your Template Files to alter the display of content depending on the conditions that the current page matches. They tell WordPress what code to display under specific conditions. Conditional Tags usually work with PHP if /else Conditional Statements and have close relation with WOrdPress Template Hierarchy. .
Warning: You can only use conditional query tags after the WP_Query is set up or with action hook.
Complete List of Conditional Tags
- is_front_page()
- is_home()
- is_front_page()
- is_home()
- is_admin()
- is_network_admin()
- is_admin_bar_showing()
- is_single()
- is_sticky()
- is_post_type_hierarchical( $post_type )
- is_post_type_archive()
- is_comments_popup()
- comments_open()
- pings_open()
- is_page()
- is_page_template()
- is_category( $category )
- is_tag()
- is_tax()
- has_term()
- term_exists( $term, $taxonomy, $parent )
- is_taxonomy_hierarchical( $taxonomy )
- taxonomy_exists( $taxonomy )
- is_author()
- is_date()
- is_year()
- is_month()
- is_day()
- is_time()
- is_new_day()
- is_archive()
- is_search()
- is_404()
- is_paged()
- is_attachment()
- wp_attachment_is_image( $post_id )
- is_local_attachment( $url )
- is_singular()
- post_type_exists( $post_type )
- is_main_query()
- is_new_day()
- is_feed()
- is_trackback()
- is_preview()
- in_the_loop()
- is_dynamic_sidebar()
- is_active_sidebar()
- is_active_widget( $widget_callback, $widget_id )
- is_blog_installed()
- is_rtl()
- is_multisite()
- is_main_site()
- is_super_admin()
- is_user_logged_in()
- email_exists( $email )
- username_exists( $username )
- is_plugin_active( $path )
- is_plugin_inactive( $path )
- is_plugin_active_for_network( $path )
- is_plugin_page()
- is_child_theme()
- current_theme_supports()
- has_post_thumbnail( $post_id )
- wp_script_is( $handle, $list )
The Conditions For …
All of the Conditional Tags test to see whether a certain condition is met, and then returns either TRUE or FALSE. The conditions under which various tags output TRUE is listed below. Those tags which can accept parameters are so noted.
The Main Page
The Front Page
The Blog Page
A Single Post Page
A PAGE Page
Has Post Thumbnail
A Single Page, a Single Post, an Attachment or Any Other Custom Post Type
A Category Page
A Tag Page
A Taxonomy Page (and related)
- is_tax()
- has_term()
- term_exists( $term, $taxonomy, $parent )
- is_taxonomy_hierarchical( $taxonomy )
- taxonomy_exists( $taxonomy )
An Author Page
A Date Page
Any Archive Page
A Search Result Page
A 404 Not Found Page
Is Dynamic SideBar
Is Sidebar Active
Is Widget Active
Is User Logged in
Email Exists
Username Exists
A Paged Page
Right To Left Reading
An Attachment
Attachment Is Image
A Local Attachment
Post Type Exists
Is Main Query
A New Day
A Syndication
A Trackback
A Preview
Has An Excerpt
Has A Nav Menu Assigned
Is Blog Installed
Part of a Network (Multisite)
An Active Plugin
- is_plugin_active( $path )
- is_plugin_inactive( $path )
- is_plugin_active_for_network( $path )
- is_plugin_page()