2013-07-29 73 views
1

如何在bootstrap popover中显示缩略图wordpress?在bootstrap popover中显示缩略图wordpress

我用the_post_thumbnail但这个功能固有地回声<img>。至于你说的产生的图像不酥料饼

<?php 
if (have_posts()) : while (have_posts()) : the_post(); 

/*********display the_post_thumbnail in data-content of popover *********/ 

echo '<a href="'.get_permalink().'" rel="popover" data-title="'.get_the_title().'" data-content="'.the_post_thumbnail('full').'">'; 


the_title(); 
echo '</a>'; 
endwhile; endif; 
wp_reset_query(); 
?> 

回答

1

所示,the_post_thumbnail()内在呼应了整个<img>标签,所以当你回音它会做意想不到的事情。做到这一点,而不是:

echo '<a href="'.get_permalink().'" rel="popover" data-title="'.get_the_title().'" data-content="'; 
the_post_thumbnail('full'); 
echo '">'; 

有一个非常好的机会,你现在必须在<img>元素与转义双引号的问题是WordPress的给你,所以它可能会更有意义,只是让缩略图网址:

$thumb = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'full'); 
$url = $thumb['0']; 


echo '<a href="'.get_permalink().'" rel="popover" data-title="'.get_the_title().'" data-content="<img src=\''.$url.'\'>">';