A developer abandoned a site and I'm trying to correct it.

The header image on this page will not show up.

This is the code in the header:

$image_id = get_post_meta(get_the_ID(), 'header_image', true );
$image= get_attached_file( $image_id, $unfiltered );
$image_path= explode('wp-content', $image);
$main_image= 'wp-content'.$image_path[1];
if ( get_post_meta( get_the_ID(), 'header_image', true ) ) : ?>
<style> .site-header { background: url("<?php echo $main_image ?>") no-repeat!important;} </style>

This section is outputting a style with a .site-header background image with a relative url; and is overwriting whatever it outputed before with the conditional is_page() codes.

Therefore, I am trying to use the custom field name "header_image with the value using the the correct url. it's not working. Every time I update, the url disappears in the value section and the original appears.

Please advise.


Just a thing to check, it happened to me as well, but I was accidently deleting some of the testing data and accidently wiped the post data for headers along with them.

So make sure that you are not deleting your data for headers somewhere - just a suggestion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.