我正在寻找一种方法,在通过下面的函数输出图像附件时,将交替的偶数/奇数类直接添加到每个图像附件:
<?php
function nongallery_img_slide( $post_id = null ) {
if ( $post_id == null ) return;
$images = get_posts(
array(
\'numberposts\' => -1,
\'post_type\' => \'attachment\',
\'post_mime_type\' => \'image\',
\'post_parent\' => $post_id,
\'orderby\' => \'menu_order\',
\'order\' => \'ASC\',
//\'exclude\' => get_post_thumbnail_id( $post_id )
)
);
if ( count( $images ) > 0 ) {
foreach ( $images as $image ) {
echo wp_get_attachment_image( $image->ID, \'photogallery-img\' );
}
}
}
?>
这能做到吗<谢谢!