Display featured image of post type category


I inherited a website that had a significant number of customized PHP files. I have removed many since, however, this is one of the few that still seemed relevant. The code below displays 1 image at random from a particular post type (gallery) in the website footer.

There was only one post type category prior to me working on the website. Now I have added more gallery categories, but the footer is displaying images from all categories. How can I modify this to show a particular category from the gallery post type?

<?php query_posts('orderby=rand&showposts=1&post_type=gallery'); 
                        while ( have_posts() ) : the_post();?>
                        $voice = '<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), "medium" ); echo $image[0]; ?>';
                        jQuery('.footer-voice').attr('src', $voice);
                        <?php endwhile; ?>
, NinjaValerie 1 year 2020-07-15T17:10:28-05:00 0 Answers 65 views 0

Leave an answer