想为FlexSlider添加一个标题,该标题已集成到购买的Wordpress Organictheme中。我相信幻灯片页面代码必须修改,虽然我在这里发现了一些类似的问题,但我还没想到(经过几个小时和失败的尝试)在哪里以及究竟要添加到现有代码中。看起来像标题应该是一个明智的选择!似乎他们应该以某种方式包含在
代码需要在这里的某个地方:
<div class="flexslider">
<ul class="slides">
<?php $data = array(
'post_parent' => $post->ID,
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order' => 'ASC',
'orderby' => 'menu_order',
'numberposts' => -1
); ?>
<?php
$images = get_posts($data); foreach( $images as $image ) {
$imageurl = wp_get_attachment_url($image->ID); echo '<li><img src="'.$imageurl.'" /></li>' . "\n";
} ?>
</ul>
</div>
答案 0 :(得分:0)
你确实很亲密。
如果有其他人需要,我会回答这个问题。缺少的两个代码是:
<p class="flex-caption"><?php echo $caption; ?></p>
... flexslider需要显示标题,
$caption = $image->post_excerpt;
...实际获得字幕。新代码将是:
<div class="flexslider">
<ul class="slides">
<?php $data = array(
'post_parent' => $post->ID,
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order' => 'ASC',
'orderby' => 'menu_order',
'numberposts' => -1
); ?>
<?php
$images = get_posts($data);
foreach( $images as $image ) {
$imageurl = wp_get_attachment_url($image->ID);
$caption = $image->post_excerpt;
echo '<li><img src="'.$imageurl.'" /><p class="flex-caption">'.$caption.'</p></li>' . "\n";
} ?>
</ul>
</div>