首先,我在一篇文章中创建了一个图库(使用内置的Wordpress图库)。
现在,由于我不喜欢Wordpress显示图库(在前端)的方式,所以在single.php页面中,我想检索该图库的图像in,因为我想使用php代码和FancyBox之类的插件创建一个自定义的图库。
我试过很多代码,但没有一个有效!我正在使用Bootstrap的Wordpress 3.5.1。
发布于 2013-03-15 19:06:14
这就是如何在WordPress中使用附加到帖子/页面的图像创建自定义图库。对于WP3.5和更早的版本也是如此。
<ul>
<?php $images = get_children('post_type=attachment&post_mime_type=image&post_parent=' . $post->ID . ' &orderby=menu_order&order=ASC');
foreach( $images as $img_id => $img_r ) :
$thumb = wp_get_attachment_image_src( $img_id, 'thumb', true );
$full = wp_get_attachment_image_src( $img_id, 'full', true ); ?>
<li>
<a href="<?php echo $full[0] ?>">
<img src="<?php echo $thumb[0] ?>" alt="<?php echo get_the_title( $img_id ) ?>" title="<?php echo get_the_title( $img_id ) ?>">
</a>
</li>
<?php endforeach; ?>
</ul>将CSS类添加到HTML以满足您的需要。
发布于 2013-03-15 19:59:52
你可以看看帖子/页面画廊提示。
它或多或少能做你想要的,你可以扩展选项。
https://stackoverflow.com/questions/15429395
复制相似问题