fancybox未在WordPress中加载图片
问题描述:
我将我的html模板转换为WordPress。 Fancybox在我的html版本中工作正常,但不是在wordpress中。fancybox未在WordPress中加载图片
在HTML版本中,的fancybox代码为:
<a href="images/p3.jpg" class="project-img fancybox"></a>
,现在在WP版本:
<a href="<?php the_post_thumbnail(); ?>" class="project-img fancybox"></a>
& jQuery的:
$(".fancybox").fancybox({
padding : 0,
margin : 100,
openEffect : 'elastic',
closeEffect : 'elastic',
openSpeed : 400,
closeSpeed : 400,
helpers : {
overlay : {
css : {
'background' : 'rgba(0, 0, 0, 0.75)'
}
}
}
});
但它不工作我,当我悬停我的图像时,它返回:
class="project-img fancybox">
我不是专业人士,所以找不到任何解决方案。
答
您正在使用href
属性中的错误功能。它显示当前帖子的精选图片(以前称为帖子缩略图),如在该帖子的编辑屏幕中设置的。该标签必须在The Loop中使用。
<a href="<?php get_the_post_thumbnail($post_id, $size, $attr); ?>" class="project-img fancybox"></a>
但问题是,我有4个职位在该节和所有动态的循环产生。如果我使用get_the_post_thumbnail(),我必须使用参数($ post_id)&我不知道如何使它动态化 – 2014-08-27 09:00:12