什么是得到所有媒体文件WordPress的功能? [英] What is the function got get all the media files wordpress?
问题描述
任何人都可以告诉我为wordpress存储所有图片的功能是什么?
预先感谢
上传的图片以attachment类型存储为帖子;使用get_posts()和正确的参数。在 Codex的get_posts()条目中,这个例子:
<?php
$ args = array(
'post_type'=>'attachment',
'numberposts'=> -1,
'post_status'=> null,
'post_parent'=> null,//任何父母
);
$ attachments = get_posts($ args);
if($ attachments){
foreach($ attachments as $ post){
setup_postdata($ post);
the_title();
the_attachment_link($ post-> ID,false);
the_excerpt();
}
}
?>
...循环显示所有附件。
如果您只是想获取图片,就像TheDeadMedic所评论的那样,您可以使用'post_mime_type'=> 'image'
在参数中。
Can anyone suggest me what is the function to get all the images stored for wordpress? I just need to list all the images seen under menu Media of the wordpress admin.
Thanks in advance
Uploaded images are stored as posts with the type "attachment"; use get_posts() with the right parameters. In the Codex entry for get_posts(), this example:
<?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();
}
}
?>
...loops through all the attachments and displays them.
If you just want to get images, as TheDeadMedic commented, you can filter with 'post_mime_type' => 'image'
in the arguments.
这篇关于什么是得到所有媒体文件WordPress的功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!