0

我试图弄清楚如何使用fancybox打开图像,但我需要在图像旁边有一个带有一些文本的div。我需要加载的文本是图像的标题,因此它不是内联文本。

4

1 回答 1

0

你至少应该先尝试。

首先,下载 Fancybox 并添加到 WordPress 主题头(index.php或者header.php,取决于您的主题结构)。

然后,调用 Fancybox 函数添加链接以弹出 Fancybox。标题可以通过以下方式找到:

$args = array( 
    'post_type'     => 'attachment', 
    'numberposts'   => -1, 
    'post_status'   => null, 
    'post_parent'   => $post->ID 
); 
// get all attachments
$attachments = get_posts($args);
foreach($attachments as $attachment) {
  $caption = $attachment->post_excerpt;
  $title = $attachment->post_title;
  // use these information in Fancybox with your logic
}
于 2013-04-16T06:47:31.990 回答