[Support request] Code to conditionally display Featured Image

Home Forums Support [Support request] Code to conditionally display Featured Image

Home Forums Support Code to conditionally display Featured Image

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1942081
    Tim

    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

    #1942123
    Leo
    Staff
    Customer Support

    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?

    #1942170
    Tim

    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).

    #1942756
    Leo
    Staff
    Customer Support

    I think the disable element would be the easiest solution here:
    https://docs.generatepress.com/article/disable-elements-overview/

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.