use*_*472 15 wordpress image function
任何人都可以建议我为wordpress存储所有图像的功能是什么?我只需要列出在wordpress admin菜单Media下看到的所有图像.
提前致谢
Mat*_*son 28
上传的图像存储为"附件"类型的帖子; 使用带有正确参数的get_posts().在get_posts()的Codex条目中,此示例:
<?php
$args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post_parent' => null, // any parent
);
$attachments = get_posts($args);
if ($attachments) {
foreach ($attachments as $post) {
setup_postdata($post);
the_title();
the_attachment_link($post->ID, false);
the_excerpt();
}
}
?>
Run Code Online (Sandbox Code Playgroud)
...遍历所有附件并显示它们.
如果您只是想获取图像,正如TheDeadMedic所评论的那样,您可以'post_mime_type' => 'image'在参数中进行过滤.
| 归档时间: |
|
| 查看次数: |
14642 次 |
| 最近记录: |