get_random_header_image

Definition:
function get_random_header_image() {}

Get random header image from registered images in theme.

Return values

returns:Path to header image

Source code

function get_random_header_image() {

	global $_wp_default_headers;



	$header_image_mod = get_theme_mod( 'header_image', '' );

	$headers = array();



	if ( 'random-uploaded-image' == $header_image_mod )

		$headers = get_uploaded_header_images();

	elseif ( ! empty( $_wp_default_headers ) ) {

		if ( 'random-default-image' == $header_image_mod ) {

			$headers = $_wp_default_headers;

		} else {

			$is_random = get_theme_support( 'custom-header' );

			if ( isset( $is_random[ 0 ] ) && !empty( $is_random[ 0 ][ 'random-default' ] ) )

				$headers = $_wp_default_headers;

		}

	}



	if ( empty( $headers ) )

		return '';



	$random_image = array_rand( $headers );

	$header_url = sprintf( $headers[$random_image]['url'], get_template_directory_uri(), get_stylesheet_directory_uri() );



	return $header_url;

}

13958

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: