I am trying to set the Featured image as the
I have tried various ways and plugins (Yoast) but finding it hard to get my head around this.
The issue is that it isn't picking up the feature image at all instead it is picking up the images in the content.
This is my current pages code for the single blog post. This is the part which i need to be able to get when sharing the blog post to Facebook rather then the content images.
<div class="image-wrapper"> <?php if( get_field('featured_image') ): ?> <?php $featuredImage = get_field('featured_image'); ?> <img rel="image_src" src="<?php echo $featuredImage['url']; ?>" alt=""> <?php else: ?> <img src="http://lorempixel.com/842/458/?rand9" alt=""> <?php endif; ?> </div>
It does do this weird thing when a blog post hasn't got any images in the content it then picks up the feature images and images in the sidebar. I also ran the Facebook debugger but again it is only picking up the contents imagery.
I did find this snippet that targets the featured image but i have a feeling because mine is a custom post it may not be picking it up.
<meta property="og:image" content="<?php $post_thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID),'large'); echo $post_thumbnail; ?>" />
Any suggestions would be great. If you need anything else, let me know.