• Susan Ryan

    (@ockeygirl84)


    Hi

    The plugin only seems to assign a featured image to a post which had a featured image set (and was subsequently deleted by me) I am using the Beaver Builder theme and plugin, all uptodate but I have imported posts from a previous wordpress install.

    Thanks in advance
    Sue

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Jan-Willem

    (@janwoostendorp)

    Hi ockeygirl,

    That’s werid bevahiour. Maybe beaverbuilder does some onder water magic.
    Is it only a matter of assigning? Or don’t they appear at the frontend at all?

    Plugin Author Jan-Willem

    (@janwoostendorp)

    A few other thing that came to mind.

    Does it work if you switch theme?
    Does it work when you disable all plugins?
    Does it happen on all post types or just posts?

    I can confirm this same problem and situation (have imported posts from a previous wordpress install).

    I’m using Sage theme with Trellis, switched to another theme but no luck, it only shows a default thumbnail when I had set a featured image before. I’ve disabled all plugins too and i’m only using default post type.

    I did some research and my guess this link bellow from Linnea explains everything:

    http://www.linsoftware.com/wordpress-has_post_thumbnail-not-working-fix-phantom-featured-image-issue/

    “The typical way to check for whether a WordPress post has a featured image is to use the function has_post_thumbnail() This function calls get_post_thumbnail_id(), which queries the database for the post meta field _thumbnail_id.

    If the field _thumbnail_id is not empty, has_post_thumbnail() will return true.

    has_post_thumbnail() does not actually check to see whether _thumbnail_id is an actual ID of an object that exists in your database. So, on the rare occasion, has_post_thumbnail() will return true when the post thumbnail does not actually exist.”

    For me, using the function wp_get_attachment_url instead of has_post_thumbnail() and checking the result if is not empty worked as desirable:

    $featured_image_url = wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ) );
    
    if  ( ! empty( $featured_image_url ) ) {
    
         // do a bunch of stuff
    
    }
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Only working on posts which had a featured image’ is closed to new replies.