I have the following code and im trying to get the images by category, I have a category name "home-hero" and when I add it into the following code it still displays all the images in the media.
How can i get it to only display all the images under home-hero?
<?php
function get_images_from_media_library() {
$args = array(
'taxonomy' => 'home-hero',
'post_type' => 'attachment',
'post_mime_type' =>'image',
'post_status' => 'inherit',
'order' => 'DESC'
);
$query_images = new WP_Query( $args );
return $query_images;
}
function display_images_from_media_library() {
$imgs = get_images_from_media_library();
$html = '<div id="media-gallery">';
global $post;
if ($imgs->have_posts()) {
while($imgs->have_posts()) {
$imgs->the_post();
$html .= '<img src="' . $post->guid . '" alt="" />';
$html .= get_the_date('F j, Y');
}
}
$html .= '</div>';
return $html;
}
echo display_images_from_media_library();
?>
Thanks for taking the time to ready.