is_random_header_image

Check if random header image is in use.

Description

is_random_header_image( (string) $type = 'any' ); 

Always true if user expressly chooses the option in Appearance > Header. Also true if theme has multiple header images registered, no specific header image is chosen, and theme turns on random headers with add_theme_support().

Parameters (1)

0. $type — Optional. (string) => 'any'
The random pool to use. any|default|uploaded

Usage

  1. if ( !function_exists( 'is_random_header_image' ) ) { 
  2. require_once ABSPATH . WPINC . '/theme.php'; 
  3.  
  4. // The random pool to use. any|default|uploaded 
  5. $type = 'any'; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = is_random_header_image($type); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/theme.php  
  1. function is_random_header_image( $type = 'any' ) { 
  2. $header_image_mod = get_theme_mod( 'header_image', get_theme_support( 'custom-header', 'default-image' ) ); 
  3.  
  4. if ( 'any' == $type ) { 
  5. if ( 'random-default-image' == $header_image_mod || 'random-uploaded-image' == $header_image_mod || ( '' != get_random_header_image() && empty( $header_image_mod ) ) ) 
  6. return true; 
  7. } else { 
  8. if ( "random-$type-image" == $header_image_mod ) 
  9. return true; 
  10. elseif ( 'default' == $type && empty( $header_image_mod ) && '' != get_random_header_image() ) 
  11. return true; 
  12.  
  13. return false;