我正在使用Twitter bootstrap主题在wordpress中工作。我刚刚制作了一个模板,从图像,名称,名称等转发器字段中获取值,我在ul和li中的模板中调用这些值,现在我希望在4 li之后会有一个hr标签或行如何实现它
以下是将转发器字段中的数据导入模板的代码:
<ul class="thumbnails">
<?php $gcount=get_post_meta($post->ID, 'europe_speaker', true);
for($i=0;$i<$gcount;$i++){
$photo=get_post_meta($post->ID, "europe_speaker_".$i."_photo", true);
$name=get_post_meta($post->ID, "europe_speaker_".$i."_name", true);
$designation=get_post_meta($post->ID, "europe_speaker_".$i."_designation", true);
$company=get_post_meta($post->ID, "europe_speaker_".$i."_company", true);
$line=get_post_meta($post->ID, "europe_speaker_".$i."_line", true);
$category=get_post_meta($post->ID, "europe_speaker_".$i."_category", true);
$download=get_post_meta($post->ID, "europe_speaker_".$i."_download", true);
$download_link=get_post_meta($post->ID, "europe_speaker_".$i."_download_link", true);
?>
<li class="span2">
<div class="speakers_img-height">
<img src="<?php echo $photo?>" class="img-polaroid" style="margin-bottom:5px;"/><br/><span style="color:#686868;"><strong><?php echo $name?></strong><br/><?php echo $designation?><br/><?php echo $company; ?><br/><a href="<?php echo $download_link; ?>"><?php echo $download; ?></a></span>
</div>
</li>
<?php }?>
</ul>
给了li span2类后,它会连续给出4 li,我想在那之后添加一行或hr标签。请帮助我们。
答案 0 :(得分:1)
试试这个jQuery代码......
jQuery("ul li:nth-child(4)").append("<hr class='whatever' />");
每四个元素尝试......
jQuery("ul li:nth-child(4n+0)").append("<hr class='whatever' />");
答案 1 :(得分:1)
非常简单:只需检查i
的价值:
for($i=0;$i<$gcount;$i++){
if (i == 3){ echo "<hr />"; }
...
请注意,检查“3”而不是“4”,因为“i
”从0开始
答案 2 :(得分:0)
在</li>
if($i==NUMBER_YOU_WANT)
{
echo"<li><hr></li>";
}
注意:您可以在<li>