Hey Guys在我的单个帖子上我有一个分享按钮..问题是分享按钮没有添加来自wordpress的精选图像,但显示了一系列图像..我需要我的帖子图像显示..我不知道任何其他方式或如何使用它机智PHP这是我的代码..
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; ?>>
答案 0 :(得分:0)
您需要将模板中的要素图像放入头部。 像这样:
<head>
<meta property="og:image" content="http://absolute_url_to_image/image.jpg" />
</head>
使用php让它变得动态。
所以:
<head>
<meta property="og:image" content="<?php echo wp_get_attachment_url( get_post_thumbnail_id($post->ID) );?>" />
</head>