我有这段代码可以在帖子上显示附加的图像:
<?php
$args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post_parent' => $post->ID,
'exclude' => get_post_thumbnail_id()
);
$attachments = get_posts( $args );
if ( $attachments ) {
foreach ( $attachments as $attachment ) {
echo '<a href="';
echo wp_get_attachment_url( $attachment->ID );
echo '" rel="lightbox">';
echo wp_get_attachment_image( $attachment->ID, 'large' );
echo '</a>';
}
}
?>
但我无法弄清楚为什么灯箱不工作!我已经尝试过 colorbox、shadowbox、ligthbox 插件等......它只是无法加载。当您单击图像时,它只会在页面中打开。
我究竟做错了什么?