Show selected image on the WordPress Messaging page

So, for all other pages on my Wordpress site, I can display an image with an image for the page. However, on a page that displays all my messages, the displayed image is not displayed, even if it is installed.

Here is the code that I use to display the displayed image on all other pages.

<?php if ( has_post_thumbnail() ): { $src = wp_get_attachment_url(get_post_thumbnail_id($post->ID)); }?> <div class="featured-image-full-width" style="background-image: url( <?php echo $src; ?> ) !important; height: 400px; background-size: cover; background-repeat: no-repeat; background-position: center;"></div> <?php endif; ?> 

This does not work on the page selected for displaying messages. Keep in mind that I need to display the image as a background image so that it is full page width and not stretch. (IE and Edge do not support "object position", so this is my way around this)

Let me know if something is unclear.

+5
source share
1 answer

After spending the last two hours researching and trying different things, I was able to find a solution.

 <?php if(is_home()) { $img = wp_get_attachment_image_src(get_post_thumbnail_id(get_option('page_for_posts')),'full'); $featured_image = $img[0]; }?> <div class="featured-image-full-width" style="background-image: url( <?php echo $featured_image ?> ) !important; height: 400px; background-size: cover; background-repeat: no-repeat; background-position: center"></div> 
+5
source

All Articles