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?
The
$page_id variable
wasn’t defined incategory.php
so I changed as seen below: