[英]Facebook share link post image pulling through
嘿伙計們在我的單個帖子上我有一個分享按鈕.. 問題是分享按鈕沒有添加來自 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; ?>>
您需要將模板中的特征圖像放入頭部。 像這樣:
<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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.