1

this is in my header

<meta property="og:image" content="<?php echo get_the_post_thumbnail($post->ID, 'thumbnail'); ?>" />

this is what is on my page so this where the featured image is taken from

while (have_posts()) : the_post(); 
   $image_share = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-share' );
   $image_post = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'counsel' );
   $image_full = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
   $comments_count = wp_count_comments( $post->ID );?>
  <h3 class="post-info-title"><p class="poster-title"><?php the_title();?></p>

  <p class="post-comment"><span class="post-comment-text">Comments</span><span class="post-commment-num"><?php echo $comments_count->approved ;?></span><img class="img-comment" src="<?php echo 'http://edge.beresponsive.net/wp-content/themes/edge-church/images/comment-img.png';?>" /></p>
  <p class="share-link-holder share-news"><a class="share-links" onclick="window.open('//player.vimeo.com/v2/video/<?php the_field('vimeo_link');?>/share/facebook', 'Facebook Share', 'width=400, height=300'); return false;" href="javascript:void(0)">Share This</a></p></h3>
  <div class="news_holder">
  <a class="news_img" href="<?php the_permalink();?>">
  </a>
  <div class="blur post-cont">
  <div class="blurb-text"> <?php the_content(); ?></div>
  </div>
  </div>

<?php endwhile; ?>>
1

2 Answers 2

0

Use get queried object

$queried_object = get_queried_object();
echo get_the_post_thumbnail($queried_object->ID, 'thumbnail');

see ref. on wp codex

0

Print the $image into your content="";

$page_id = get_queried_object_id();
if ( has_post_thumbnail( $page_id ) ) :
    $image_array = wp_get_attachment_image_src( get_post_thumbnail_id( $page_id ), 'optional-size' );
    $image = $image_array[0];
else :
    $image = get_template_directory_uri() . '/images/default-bg.jpg';
endif;
<meta property="og:image" content="<?php  echo $image; ?>" />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.