Php 如何在wordpress中获取文章的图像url?
我正在为Wordpress开发Pinterest pinit插件。Pinterest pinit按钮需要图像URL和post URL。。。如何获取图像URL 我使用了以下代码,但没有成功:Php 如何在wordpress中获取文章的图像url?,php,wordpress,pinterest,Php,Wordpress,Pinterest,我正在为Wordpress开发Pinterest pinit插件。Pinterest pinit按钮需要图像URL和post URL。。。如何获取图像URL 我使用了以下代码,但没有成功: $pid=get_the_ID(); $image_id = get_post_thumbnail_id($pid); $image_url = wp_get_attachment_image_src($image_id); echo $image_url[0]; 有人能帮忙吗 你也试过这个吗 $url =
$pid=get_the_ID();
$image_id = get_post_thumbnail_id($pid);
$image_url = wp_get_attachment_image_src($image_id);
echo $image_url[0];
有人能帮忙吗 你也试过这个吗
$url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
<img src="<?php echo $url; ?>" />
$url=wp\u get\u attachment\u url(get\u post\u缩略图\u id($post->id));
" />
您也可以这样使用,$catposts是一个以帖子为特色的图像查询
$category_id = 'your_category_id'; $NUMBEROFPOSTS = '4'; $catposts = get_posts('category='.$category_id."&order=DESC&numberposts=".$NUMBEROFPOSTS);
foreach ($catposts as $item) :
echo '<li class="active" style="height: 100px; width: 71px;">';
echo '<a href="'.get_permalink( $item->ID ).'">';
echo '<img src="'.wp_get_attachment_url( get_post_thumbnail_id($item->ID)).'">';
echo '</a>';
echo '</li>';
endforeach;
$category_id='your_category_id';$NUMBEROFPOSTS='4';$catposts=get_posts('category='.$category_id.&order=DESC&numberposts=“.NUMBEROFPOSTS”);
foreach($catposts作为$item):
echo'';
回声';
回音“ ”;
endforeach;
当前您正在获取文章中的特色图片id。您是否正在尝试获取特色图片?