Lego2012
12/13/2016 - 4:32 PM

If Conditionals

If Conditionals

<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.

<!-- Checking for multiple CPTs in all views: -->

// if not a lesson or WooCommerce product page (single or archive), abort.
    if ( ! in_array( get_post_type(), array( 'lessons', 'product' ) ) ) {
        return;
    }

<!-- Entries of a specific CPT in all views: -->

if ( 'research-papers' === get_post_type() )

<!-- All Static Pages: -->

is_page()

<!-- All single Posts: -->

is_singular( 'post' )

<!-- Any single Post or static Page: -->

is_singular( array( 'post', 'page' ) )

<!-- A specific custom taxonomy's archives: -->

is_tax( 'product_cat' )

<!-- A specific term's archive page: -->

is_tax( 'product_cat', 'accessories' )

<!-- where 'product_cat' is the custom taxonomy. -->

<!-- Single CPT entry page having a specific term: -->

has_term( 'accessories', 'product_cat' )

<!-- where 'product_cat' is the custom taxonomy. -->

<!-- Any WooCommerce shop page that is not a shop archive page or single product page -->

!( is_tax( 'product_cat' ) || has_term( '', 'product_cat' ) )

<!-- Category page or single page for WooCommerce products that belong to Parts or Gear -->

is_tax( 'product_cat', 'parts' ) || is_tax( 'product_cat', 'rhodan-gear' ) || has_term( 'parts', 'product_cat' ) || has_term( 'rhodan-gear', 'product_cat' )

<!-- Category page or single page for WooCommerce products that belong to Motors -->

is_tax( 'product_cat', 'gps-guided-trolling-motors' ) || has_term( 'gps-guided-trolling-motors', 'product_cat' )

<!-- Category page or single page for WooCommerce products that belong to Accessories -->

is_tax( 'product_cat', 'accessories' ) || has_term( 'accessories', 'product_cat' )

<!-- Any WooCommerce page: -->

if ( is_shop() || is_singular( 'product' ) || is_tax( 'product_cat' ) )

<!-- Conditional tag to check if current page is displaying event query when using The Events Calendar: -->

tribe_is_event_query()