Php WordPress图库行的最后一项
以下是html:Php WordPress图库行的最后一项,php,wordpress,wordpress-theming,Php,Wordpress,Wordpress Theming,以下是html: <div id="gallery-1" class="gallery galleryid-429 gallery-columns-5 gallery-size-thumbnail"> <dl class="gallery-item"></dl> <dl class="gallery-item"></dl> <dl class="gallery-item"></dl> <dl class=
<div id="gallery-1" class="gallery galleryid-429 gallery-columns-5 gallery-size-thumbnail">
<dl class="gallery-item"></dl>
<dl class="gallery-item"></dl>
<dl class="gallery-item"></dl>
<dl class="gallery-item"></dl>
<dl class="gallery-item"></dl>
<br style="clear: both">
<dl class="gallery-item"></dl>
<dl class="gallery-item"></dl>
<dl class="gallery-item"></dl>
</div>
因此,我在每第五项之后都有br style=“clear:both”。有人能帮我把MyCSS类添加到第五项中吗
以下是php wp函数:
$i = 0;
foreach ( $attachments as $id => $attachment ) {
$link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false);
$output .= "<{$itemtag} class='gallery-item'>";
$output .= "
<{$icontag} class='gallery-icon'>
$link
</{$icontag}>";
if ( $captiontag && trim($attachment->post_excerpt) ) {
$output .= "
<{$captiontag} class='wp-caption-text gallery-caption'>
" . wptexturize($attachment->post_excerpt) . "
</{$captiontag}>";
}
$output .= "</{$itemtag}>";
if ( $columns > 0 && ++$i % $columns == 0 )
$output .= '<br style="clear: both" />';
}
$output .= "
</div>\n";
return $output;
$i=0;
foreach($id=>$attachment的附件){
$link=isset($attr['link'])和&'file'=$attr['link']?wp_获取附件链接($id,$size,false,false):wp_获取附件链接($id,$size,true,false);
$output.=“”;
$output.=”
$link
";
如果($captiontag&&trim($attachment->post_摘录)){
$output.=”
“.wptexturize($attachment->post_摘录)。”
";
}
$output.=“”;
如果($columns>0&&++$i%$columns==0)
$output.='
;
}
$output.=”
\n”;
返回$output;
您可以使用以下CSS将每五个元素作为目标:
.gallery-item:nth-child(5n+5) {
/* css */
}
我知道,但是wordpress管理面板中的5是可选的。它可以是2,5,等等。所以,它不会有帮助。然后你需要读取那个“可选”值并将其放入CSS中。你的工作。