Site logo

Archived topic

Code to conditionally display Featured Image

3 replies · Started by Tim on September 24, 2021

Viewing posts 1–4 of 4

Hi,

I am wondering if it's possible to conditionally display the featured image so that it only displays on posts with a featured image of 800px or wider using PHP?

I'm currently using CSS to "display: none" on posts with a certain tag because that was the easiest thing for me to do but that's not ideal. And if possible I need the code to not impact anything other than posts (for example I need the featured images shown in archives to stay as is).

Thank you for your help with this.

Tim

Hi Tim,

I'm not sure if there is a solution for this unfortunately.

Stupid question - if you don't want the featured image to display when it's smaller than 800px, wouldn't it be easier to just not load a featured image?

Ah ok, what conditions are there for displaying/not displaying a featured image on certain posts?

It would, but I insert a featured image no matter what because I always want it to display in the archives (blog page/category pages etc).

This archived topic is closed to new replies.