如何从wordpress中的特定帖子id获取附件 $argsThumb=数组( “订单”=>“ASC”, “post_类型”=>“附件”, 'post_parent'=>$post->ID, “post_mime_type”=>“image”, “post_状态”=>null ); $attachments=get_posts($argsThumb); 若有($附件){ foreach($attachments as$attachment){?>
只接受一个参数+您需要回显:如何从wordpress中的特定帖子id获取附件 $argsThumb=数组( “订单”=>“ASC”, “post_类型”=>“附件”, 'post_parent'=>$post->ID, “post_mime_type”=>“image”, “post_状态”=>null ); $attachments=get_posts($argsThumb); 若有($附件){ foreach($attachments as$attachment){?>,wordpress,Wordpress,只接受一个参数+您需要回显: 注意:要获得特定的图像大小,请使用问题是什么?您的代码段不工作?是否有错误?它是否返回任何内容?但显示附件图像,问题是显示所有媒体图像文件。我只想在该帖子中使用 $argsThumb = array( 'order' => 'ASC', 'post_type' => 'attachment', 'post_parent' => $post->ID, 'post_mime_ty
注意:要获得特定的图像大小,请使用问题是什么?您的代码段不工作?是否有错误?它是否返回任何内容?但显示附件图像,问题是显示所有媒体图像文件。我只想在该帖子中使用
$argsThumb = array(
'order' => 'ASC',
'post_type' => 'attachment',
'post_parent' => $post->ID,
'post_mime_type' => 'image',
'post_status' => null
);
$attachments = get_posts($argsThumb);
if ($attachments) {
foreach ($attachments as $attachment) { ?>
<div class="item">
<a href="<?php wp_get_attachment_url($attachment->ID, 'large', false, false); ?>" class="zoom" rel="group">
<span class="thumb">
<img class="small" src="<?php wp_get_attachment_url($attachment->ID, 'medium', false, false); ?>" />
</span>
</a>
</div>
<?php } } ?>