Loop through all media library images and return those where caption contains the text carousel

Im new to WordPress but I’m looking for a way to loop through all the images that have been uploaded to the media library and output the SRC, description and caption of the image when the caption contains the word ‘carousel’. Is this possible? 1 Answer 1 You could do this pretty easily with a … Read more

Why does SVG upload in Media Library fail if the file does not have an XML tag at the beginning?

I have enabled SVG uploads using this code: add_filter(‘upload_mimes’, function($mimes) { $mimes[‘svg’] = ‘image/svg+xml’; return $mimes; }); However, uploads of SVG files that start with the <svg> tag fail with the usual “Sorry, this file type is not permitted for security reasons.” error that WordPress displays when SVG uploads are not supported. If I add … Read more

Getting alt text of featured image

I’m trying to get the alt text of our featured image and have it output on the frontend. Currently my code is <img class=”vehicle-photo” src=”https://wordpress.stackexchange.com/questions/312283/<?php echo the_post_thumbnail_url() ?>” alt=”<?php the_post_thumbnail_caption();?>” /> But on the frontend, it is outputting as <img class=”vehicle-photo” src=”https://wordpress.stackexchange.com/questions/312283/photo url here” alt=””> 2 Answers 2 The alt text is stored as post … Read more