How to filter a WordPress gallery by category

WordPress’s own Gallery block has no filter: every photo shows, always. To let visitors pick “Weddings” or “Portraits” and see only those, the photos need categories, and the page needs buttons that hide the rest. This guide sets that up in the block editor with the free Wisp Gallery plugin, in about ten minutes.

What you need

  • WordPress 6.6 or later, with the block editor (block or classic theme).
  • The free Wisp Gallery plugin: Plugins → Add New, search for “Wisp Gallery”, install and activate.
  • Photos in the Media Library.

1. Give your photos categories

Wisp Gallery adds Gallery Categories, a taxonomy that sits on the image itself. Tag a photo once and every gallery that shows it filters it correctly.

The quickest way to tag a whole shoot:

  1. Go to Media → Library and switch to the list view.
  2. Tick the photos that belong together.
  3. Choose Add to gallery category… in the bulk actions, pick or create a category, and click Apply.

Keep the names short: they become the button labels. A photo can be in more than one category. You can also tag images later, right in the gallery: select them and use the tag button in the block toolbar. More in Categories & Media Library.

  1. Open the page and add a Filterable Gallery block.
  2. Drop in photos, or pick them from the Media Library. To show every photo of some categories, including ones you upload later, add a Gallery Media Query inside the gallery and select the categories.
  3. Pick a layout in the sidebar: masonry, justified rows, grid, carousel or accordion. Columns, row height and cropping can differ for desktop, tablet and mobile.

3. Add the filter buttons

  1. Add a Gallery Filter block above the gallery. Under Gallery, pick this gallery, or let it filter every gallery on the page.
  2. In its settings, choose which categories show and in which order, whether there is an “All” button, and whether each button shows a count.
  3. Under Display as, pick buttons, a dropdown, or buttons that turn into a dropdown on phones.

The buttons use your theme’s own button style, so they match the rest of the site without any CSS. Publish, click a button on the front end, and the photos move into place with a short animation.

To see the result on real pages: the wedding photography demo filters one wedding by chapter, the restaurant menu demo by course, and the florist demo by bouquets, weddings, workshops and the shop.

Filtering posts too

Portfolios often mix single photos with project pages. Posts and pages have the same Gallery Categories (in the post sidebar), so one filter can cover both: add a Query Loop with the Gallery Posts variation inside the gallery, next to the images. The tutorial Filterable portfolios with posts and images in one gallery walks through it.

What it costs your page

The first gallery on a page loads about 3 KB of JavaScript. The lightbox and carousel load only when a gallery uses them, images are lazy-loaded at the right size, and the scroll reveal runs in CSS. The 100-photo demo shows a filtered masonry gallery at that size.

With Wisp Gallery Pro

Everything above is free. Wisp Gallery Pro ($29 a year) adds a link for each category, such as ?category=weddings, that opens the page already filtered, filtering by any taxonomy (for example regular post categories), more filter styles and presets, and load more for large galleries.

Want to try it first? Open Wisp Gallery in a live WordPress, right in your browser, with sample photos and a filter already set up.