Php 排除帖子缩略图?
我正在使用下面的代码获取我主题中每个帖子的附加图像,以便在幻灯片中使用。它工作得很好,因为它能够检索所有附加的图像,但它也包括 所以我的问题是,有没有一种方法可以只排除Php 排除帖子缩略图?,php,wordpress,Php,Wordpress,我正在使用下面的代码获取我主题中每个帖子的附加图像,以便在幻灯片中使用。它工作得很好,因为它能够检索所有附加的图像,但它也包括 所以我的问题是,有没有一种方法可以只排除特色图片,而显示其余的图片 PHP 函数bdw\u get\u图像($postId){ $iPostID=$postId; $arrImages=&get_children('post_type=attachment&post_mime_type=image&post_parent='。$iPostID); 如果($ARR图像)
特色图片
,而显示其余的图片
PHP
函数bdw\u get\u图像($postId){
$iPostID=$postId;
$arrImages=&get_children('post_type=attachment&post_mime_type=image&post_parent='。$iPostID);
如果($ARR图像){
$arrKeys=数组_键($arrKeys);
foreach($arr图像为$oImage){
$arrNewImages[]=$oImage;
}
对于($i=0;$i菜单顺序>(int)$arrNewImages[$j+1]->菜单顺序){
$oTemp=$arrNewImages[$j];
$arrNewImages[$j]=$arrNewImages[$j+1];
$arrNewImages[$j+1]=$oTemp;
}
}
}
$arrKeys=array();
foreach($arrNewImages作为$oNewImage){
$arrKeys[]=$oNewImage->ID;
}
$iNum=$arrKeys[0];
foreach($arrKeys作为$key){
$sImageUrl=wp\u get\u attachment\u url($key);
$sImgString='';
echo$sImgString;
}
}
}
bdw_获取_图像($post->ID);
通过Get\u post\u thumbnail\u id($post\u id)函数获取帖子缩略图(如果有),并在最后一个循环中检查。
最后一个循环应该是这样的:
$post_thumbnail_id = get_post_thumbnail_id( $iPostID );
foreach( $arrKeys as $key) {
if( $key == $post_thumbnail_id )
continue;
$sImageUrl = wp_get_attachment_url($key);
$sImgString = '<img src="' . $sImageUrl . '" alt="Thumbnail Image" />';
echo $sImgString;
}
$post\u thumboil\u id=get\u post\u thumboil\u id($iPostID);
foreach($arrKeys作为$key){
如果($key==$post\u缩略图\u id)
继续;
$sImageUrl=wp\u get\u attachment\u url($key);
$sImgString='';
echo$sImgString;
}
如果所有帖子的特色图片索引都是相同的,也许你应该用php忽略它。谢谢!我会尽快检查这是否有效。
$post_thumbnail_id = get_post_thumbnail_id( $iPostID );
foreach( $arrKeys as $key) {
if( $key == $post_thumbnail_id )
continue;
$sImageUrl = wp_get_attachment_url($key);
$sImgString = '<img src="' . $sImageUrl . '" alt="Thumbnail Image" />';
echo $sImgString;
}