Support » Fixing WordPress » Slideshow of all the images in the Media Library?

  • roadie

    (@roadie)


    I would like to create a page on my WordPress website that shows a slideshow of all the images in the Media Library, one by one.
    I first thought that including a shortcode such as
    [ gallery type="slideshow" ]
    would do the trick, but that would only show any images already attached to the page.

    [ gallery type="slideshow" ids="729,732,731,720"] etc
    might do it, but would be tedious to set up and keep updated.

    I would really prefer something like
    [ gallery type="slideshow" ids="all"]
    or
    [ gallery type="slideshow" include="all"]

    I would also want to just show the image and its title, without any sidebars or post text etc, but I guess I could do that with custom CSS.

    I wonder if you have any suggestions.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    You could try searching for other slideshow plugins that can provide the behavior you are after. I would think you would at least want to exclude a few images from an “all” request. For example, the site icon added in the customizer should probably not be in the overall image slideshow.

    If an existing plugin cannot be found, you could alter the images queried for by the normal gallery shortcode through the “pre_get_posts” action. Yes, this means custom coding. The gallery query is the same query used to get any WP posts or pages, except the query is for attachments with image MIME types. Your action callback can alter the query vars used so the query gets all image attachments instead of the default ones attached to the current post.

    Your callback must be sure to only alter the correct query, as all queries pass through this same action. I believe you can actually pass an ids="all" parameter even though the default gallery wouldn’t know what that means. Your callback could look for this value in the “post__in” query var as a signal that it’s the correct query to alter. The value should then be unset so WP doesn’t get confused. Set other query vars as needed to get the results you want.

Viewing 1 replies (of 1 total)
  • The topic ‘Slideshow of all the images in the Media Library?’ is closed to new replies.