Wrong featured image with Builder Themer

There is a bug with the beaver builder themer plugin which started to happen a few versions ago.

With the latest versions, the featured image is not the correct image being shown. In our site we have a featured post at the top of the page with its own layout, and then the older posts below it. I believe this happens when there is a multiple posts being shown on the same page.

I wasn’t able to find the actual bug causing this, but I was able to narrow it down and find a workaround in the meantime. I also wasn’t able to hook the function. Hopefully this workaround will help show you what is going on code wise so you push out a fix, or make it hookable so I can make it properly on my end so I can keep it updated.

FILE: /plugins/bb-theme-builder/classes/class-fl-page-data-post.php
LINE: 222
FUNCTION: get_featured_image_url()
REPLACE ENTIRE FUNCTION WITH:

static public function get_featured_image_url( $settings ) {
		global $post;		
                $fi = get_transient( 'featured_blog_image_url_temp' );
		$featured_image = unserialize($fi);
		if(is_singular('post')){
			//single image
			if($featured_image['id']!=$post->ID){
				$id  = '';
				$url = '';
				
				if ( has_post_thumbnail( $post ) ) {
					$id  = get_post_thumbnail_id( $post->ID );
					$url = get_the_post_thumbnail_url( $post, $settings->size );
				} elseif ( isset( $settings->default_img_src ) ) {
					$id  = $settings->default_img;
					$url = $settings->default_img_src;
				}
				return array(
					'id'  => $id,
					'url' => $url,
				);
			}
		}
		else{
			//featured image
			if($fi && $fi!=''){
				$id = $featured_image['id'];
				$url = $featured_image['url'];
			}
			else{
				$id  = '';
				$url = '';
		
				if ( has_post_thumbnail( $post ) ) {
					$id  = get_post_thumbnail_id( $post->ID );
					$url = get_the_post_thumbnail_url( $post, $settings->size );
				} elseif ( isset( $settings->default_img_src ) ) {
					$id  = $settings->default_img;
					$url = $settings->default_img_src;
				}
				set_transient( 'featured_blog_image_url_temp', serialize(array('id'=>$id, 'url'=>$url)), 86400 );
			}
	
			return array(
				'id'  => $id,
				'url' => $url,
			);
		}
	}

@Danny any thoughts?

Just checking if this was resolved @abda53 ? I have been experiencing this for some time - had my designer look at it but it is still happening with new posts. Wrong featured image on blog list page. Thanks for your help.

No I don’t believe so, but I forgot about it until you replied. Your developer should be able to use my code and troubleshoot it to see where the issue is happening and figure out the fix.

@pross @robby @Danny @katd any suggestions?