问题描述
想为FlexSlider添加标题,该标题已集成到购买的Wordpress Organictheme中.我相信必须修改幻灯片页面的代码,尽管我在这里发现了一些类似的问题,但我还没有弄清楚(经过数小时和失败的尝试)在现有代码中的确切位置和确切位置.似乎字幕很容易理解!似乎它们应该以某种方式包含在
Would like to add a caption to FlexSlider, which is integrated into a purchased Wordpress Organictheme. I believe the slideshow page code must be modified and though I have found some similar issues here, I have not figured out (after many hours and failed attempts) where and what exactly to add to the existing code. Seems like captions should be a no-brainer! Seems like they should somehow be included within the
tags??? Would REALLY APPRECIATE some help. html, but NOT php literate. THANK YOU!代码需要放在这里:
<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>
推荐答案
您确实非常亲密.
如果有人需要,我会回答.代码的两个缺失位是:
I'll answer this in case someone else needs it. The two missing bits of code are:
<p class="flex-caption"><?php echo $caption; ?></p>
... flexslider要求显示字幕,并且
... required by flexslider to display the captions, and
$caption = $image->post_excerpt;
...以实际获取字幕.新代码将是:
... to actually obtain the captions. New code would be:
<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>
这篇关于在Wordpress Organictheme上为集成的FlexSlider添加标题.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!