Skip to main content
replaced http://wordpress.stackexchange.com/ with https://wordpress.stackexchange.com/
Source Link

I'm using a customized version of the Twenty Eleven theme. I want to set a class on the body based on which random header image is displayed. Is there some function that allows me to get the name of the custom header image that will be displayed? My goal is to style the text / background / colors based on the image being displayed.

Edit: I used Brian's answerBrian's answer, placing the $header_image code before the <body> tag, and also made some changes in header.php. I had to comment out the existing call to get_header_image():

// Check to see if the header image has been removed
//$header_image = get_header_image();

I also changed the header img tag to use the $header_image variable instead of using a call to header_image() to get the file path:

<img src="<?php /*header_image();*/ echo $header_image; ?>"
    width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>"
    alt="" />

I'm using a customized version of the Twenty Eleven theme. I want to set a class on the body based on which random header image is displayed. Is there some function that allows me to get the name of the custom header image that will be displayed? My goal is to style the text / background / colors based on the image being displayed.

Edit: I used Brian's answer, placing the $header_image code before the <body> tag, and also made some changes in header.php. I had to comment out the existing call to get_header_image():

// Check to see if the header image has been removed
//$header_image = get_header_image();

I also changed the header img tag to use the $header_image variable instead of using a call to header_image() to get the file path:

<img src="<?php /*header_image();*/ echo $header_image; ?>"
    width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>"
    alt="" />

I'm using a customized version of the Twenty Eleven theme. I want to set a class on the body based on which random header image is displayed. Is there some function that allows me to get the name of the custom header image that will be displayed? My goal is to style the text / background / colors based on the image being displayed.

Edit: I used Brian's answer, placing the $header_image code before the <body> tag, and also made some changes in header.php. I had to comment out the existing call to get_header_image():

// Check to see if the header image has been removed
//$header_image = get_header_image();

I also changed the header img tag to use the $header_image variable instead of using a call to header_image() to get the file path:

<img src="<?php /*header_image();*/ echo $header_image; ?>"
    width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>"
    alt="" />
Tweeted twitter.com/#!/StackWordPress/status/166306798943481856
Adding answer details
Source Link

I'm using a customized version of the Twenty Eleven theme. I want to set a class on the body based on which random header image is displayed. Is there some function that allows me to get the name of the custom header image that will be displayed? My goal is to style the text / background / colors based on the image being displayed.

Edit: I used Brian's answer, placing the $header_image code before the <body> tag, and also made some changes in header.php. I had to comment out the existing call to get_header_image():

// Check to see if the header image has been removed
//$header_image = get_header_image();

I also changed the header img tag to use the $header_image variable instead of using a call to header_image() to get the file path:

<img src="<?php /*header_image();*/ echo $header_image; ?>"
    width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>"
    alt="" />

I'm using a customized version of the Twenty Eleven theme. I want to set a class on the body based on which random header image is displayed. Is there some function that allows me to get the name of the custom header image that will be displayed? My goal is to style the text / background / colors based on the image being displayed.

I'm using a customized version of the Twenty Eleven theme. I want to set a class on the body based on which random header image is displayed. Is there some function that allows me to get the name of the custom header image that will be displayed? My goal is to style the text / background / colors based on the image being displayed.

Edit: I used Brian's answer, placing the $header_image code before the <body> tag, and also made some changes in header.php. I had to comment out the existing call to get_header_image():

// Check to see if the header image has been removed
//$header_image = get_header_image();

I also changed the header img tag to use the $header_image variable instead of using a call to header_image() to get the file path:

<img src="<?php /*header_image();*/ echo $header_image; ?>"
    width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>"
    alt="" />
edited title
Link
Brian Fegter
  • 10k
  • 1
  • 41
  • 60

how How to determine which custom header image is being shown

Source Link
Loading