Featured images not showing correctly
-
Hi,
I have two problems.
1. Featured image are not showing for my posts loop.
https://i.postimg.cc/Kc1fzxss/Capture-d-cran-2021-05-09-203147.pngHave no idea what’s the problem.
$f_image = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large' );
<div class="swiper-article" style="background-image:url(<?php echo $f_image[0] ?>)">
2. I have a problem with a page where it shows the post title instead of the page title and it also show the post image instead.
https://i.postimg.cc/h4NrQ6k4/Capture-d-cran-2021-05-09-203345.png
https://i.postimg.cc/gkRKV4pV/Untitled.pngThe page featured-image is inside a template part, so not on this page php file. It works for other pages, but this one is having a problem.
Page header:
//Variables $page_image = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' ); ?> <!-- PAGE FEATURED IMAGE --> <section class="page-header"> <div class="featured-image-container"> <div class="featured-image" style="<?php if($page_image) echo 'background-image:url(\''.$page_image[0].'\')' ?>"></div> <div class="img-overlay"></div> <div class="page-title"> <?php the_title('<h1>', '</h1>'); ?> <?php if ( has_excerpt() ) : ?> <h2><?php echo get_the_excerpt(); ?></h2> <?php endif; ?> </div> </div> </section>
Inside this page php:
<div <?php post_class( 'album-card' ); ?> id="post-<?php the_ID(); ?>"> <a href="<?php echo esc_url( get_permalink() ); ?>"> <div class="album-background" style="<?php if($album_image) echo 'background-image:url(\''.$album_image[0].'\')' ?>"> <div class="album-title"> <h3><?php the_title(); ?></h3> </div> <div class="overlay"></div> </div> </a> </div>
The $album_image is called previously
$album_image = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' );
I don’t really know how to debug this. Looks like it doesn’t make difference between the page thumbnail and post thumbnail in the loop. Like if it’s was the same thing…
- The topic ‘Featured images not showing correctly’ is closed to new replies.