Quote:
Originally Posted by BCyber
I'm trying to change some code to get ONLY the featured images from the media library in wordpress. I'm losing my mind, any ideas? Here's some of the code.
|
Code:
{
$homepage_items = -1;
$args = array(
'post_type' => 'attachment',
'numberposts' => $homepage_items,
'post_status' => null,
'post_parent' => $post->ID,
'order' => 'ASC',
'orderby' => 'menu_order',
'meta_key' => '_thumbnail_id'
);
$all_photo_arr = get_posts( $args );
}
You could also then sort them by meta_value if you so desire using "'orderby' => 'meta_value'" and then set "'order' => 'ASC|DESC'" (either or, not both)
The above of course assuming that you only want posts with a featured image... if not then
http://codex.wordpress.org/Function_...post_thumbnail