Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm referencing an attached image in my header.php page which is displayed as a full screen background on my posts:

global $wp_query;
$page_id = $wp_query->get_queried_object_id();
$background_image = get_post_meta($page_id, 'mb_background_image', true);
$src = wp_get_attachment_image_src($background_image, 'full');

This works fine on single posts, but doesn't work when displaying just one post per page in category.php.

How can I fix this?

Thanks

share|improve this question
add comment

1 Answer 1

up vote 0 down vote accepted

The $page_id variable wasn't defined in category.php so I changed it to this.

$background_image = get_post_meta($post->ID, 'mb_background_image', true);
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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