Plugins Plugin hub Backup SEO Caching Security Forms WooCommerce Images Best backup plugins
Hosting Hosting directory Shared hosting Managed WordPress Cloud hosting VPS hosting By reader location Hosting finder
Themes & builders Compare Rank Math vs Yoast
Tools All tools Hosting finder Plugin stack builder Cost calculator Salt generator Theme detector Who is hosting this? Speed test Headline analyzer robots.txt generator Redirect generator Uptime calculator Blog name generator
Blog Best backup plugins Deals
Guides All guides Speed up WordPress Choose hosting Back up WordPress
How we test

Blogging & content · Guide

How to Create a Gallery in WordPress (Step by Step)

How to Create a Gallery in WordPress (Step by Step)

Short answer

Add a Gallery block in the WordPress editor, then upload images or choose them from the Media Library and insert them. Use the block sidebar to set columns, cropping, image size and what happens when someone clicks an image. Add captions and alt text to each image before you publish.

Key takeaways

  • The Gallery block is built into WordPress, so no plugin is needed.
  • Each image in a Gallery block is its own Image block.
  • Columns, cropping, links and size are set in the sidebar.
  • Add alt text to every image for accessibility and search.
  • Classic galleries use the gallery shortcode with image IDs.
  • Use a gallery plugin for albums, filters or proofing.

Add a Gallery block to your post or page, upload images or pick them from the Media Library, then set columns, cropping, links and captions in the block settings.

The Gallery block is part of WordPress core, so you do not need a plugin for a simple, responsive image grid.

Since WordPress 5.9, each picture inside a Gallery block is its own Image block. That means you can give individual images their own captions, links and styles.

The steps below cover the block editor, the older classic gallery shortcode, page builders and when a gallery plugin is worth it.

Click the plus icon in the editor, search for Gallery and select it, or type /gallery on a new line and press Enter.

The block appears with three options: Upload, Media Library and, in some versions, Insert from URL.

You can also drag several image files from your computer straight onto an empty Gallery block. WordPress uploads them and adds them in one step.

The official Gallery block documentation shows the block with each control labeled.

Click Media Library, select several images by clicking each one, then click Create a new gallery, arrange them in the next screen and click Insert gallery.

In the media window, clicking each image adds it to the selection. A tick appears on every image you have chosen, and clicking again removes it.

On the next screen, drag images to change their order. You can also add captions here before inserting.

To add more images later, select the Gallery block and click Add in its toolbar. New images join the end of the gallery.

Step 3: How do you set the number of columns?

Select the Gallery block, open the Settings sidebar and move the Columns slider to choose how many images sit in each row.

The default depends on how many images you add, up to a maximum. Three or four columns suit most content widths.

On phones, galleries collapse to fewer columns automatically. Check the mobile view in the editor's device preview.

Crop images to fit makes every image the same size, which gives a neat grid. Turn it off to keep each image's original shape, which suits mixed portrait and landscape shots.

Step 4: How do you set what happens when someone clicks an image?

Choose a Link setting for the gallery, such as no link, link to the media file, link to the attachment page or open a larger view on click, depending on your WordPress version.

None keeps images static. This is a good choice for decorative galleries.

Media File opens the full image file in the browser. Many lightbox plugins hook into this setting to show images in a pop-up.

Attachment Page opens a separate page for each image. Newer installs turn attachment pages off by default, so this option may not appear.

Recent WordPress versions also offer an expand-on-click option that shows a larger image in an overlay without a plugin. Check the link options in your own editor, since labels have changed between releases.

Step 5: How do you add captions and alt text?

Click an image inside the gallery to add a caption below it, and add alt text in the sidebar so screen readers and search engines understand each image.

The whole gallery can also have its own caption, which sits below the grid.

Alt text should describe what matters about the image in context. The W3C's alt text decision tree helps you decide when and how to write it.

Our guide on optimizing images for SEO covers file names, alt text and captions in more detail.

Use the Resolution or image size setting in the sidebar to pick which registered size the gallery shows, such as Medium, Large or Full Size.

Smaller sizes load faster. Large is usually enough for a three or four column grid, while Full Size is rarely needed.

WordPress adds responsive image attributes, so browsers can still choose smaller files on phones.

Our guide on properly sizing images in WordPress explains registered sizes and how to change them.

Use the Styles options in the sidebar to change the gap between images, add rounded corners or borders, and pick any style presets your theme provides.

Block spacing controls the gap between images. A small gap looks tidy, while no gap creates a seamless mosaic.

Some themes add their own gallery styles, such as rounded or framed images. They appear as presets under Styles when the block is selected.

You can also style a single image inside the gallery. Select it and change its border or radius, though a consistent look usually works better.

For site-wide changes, open the Site Editor, go to Styles, choose Blocks and then Gallery. Every gallery on the site picks up those defaults.

Click the gallery to select it, then add, remove or reorder images, or click a single image to replace it or change its caption.

To remove an image, select it inside the gallery, open its options menu and choose Delete. The file stays in the Media Library.

To swap an image, select it and click Replace in its toolbar. Its caption and link settings may need updating afterwards.

If you want to turn a gallery back into separate images, select the gallery and use the transform option in its toolbar to convert it to Image blocks.

In the Classic Editor, click Add Media, choose Create Gallery, select your images, click Create a new gallery, adjust settings and click Insert gallery.

This inserts a [gallery] shortcode with the IDs of the chosen images. WordPress turns it into a grid when the page loads.

The shortcode supports options such as columns, size and link. The gallery_shortcode() reference lists them all.

To find the IDs used in a shortcode, see our guide on how to get an image ID in WordPress.

Drag the Basic Gallery widget, or the Gallery widget in Elementor Pro, onto the page, add images and set columns, spacing, link behavior and lightbox options in the widget panel.

Elementor's lightbox is built in, so clicking an image opens a larger view without another plugin.

The Pro Gallery widget adds layouts such as masonry and justified, plus filterable galleries with tabs for different image groups.

Use a gallery plugin when you need albums, filtering, advanced lightboxes, proofing for clients or very large image collections that the core block does not handle well.

Popular options include FooGallery, NextGEN Gallery, Envira Gallery and Modula. Each has a free version with paid upgrades.

Photographers and portfolio sites often benefit from these extras. Most blogs and business sites do not need them.

NeedBest option
Simple image grid in a postCore Gallery block
Old posts using shortcodesClassic gallery shortcode
Built-in lightbox and masonryElementor gallery widgets or a plugin
Albums and filtersGallery plugin
Client proofing or salesSpecialist photography plugin

How do you keep galleries fast?

Compress images before upload, use a sensible display size, and let browsers lazy-load images below the first screen.

Galleries can hold dozens of images, which adds a lot of page weight. Every file you shrink makes a real difference.

WordPress adds native lazy loading to most images. web.dev's guide to browser-level lazy loading explains how it works.

Our guide on optimizing images for WordPress covers compression and formats.

For images further down long galleries, see our guide to lazy loading images.

Upload failures usually come from file size limits, unsupported formats, folder permissions or a server error during image processing.

Try a smaller file first. If that works, ask your host to raise upload limits or resize images before uploading.

For the generic upload failure message, see our fix for the HTTP error when uploading images.

Frequently asked questions

How do I make a photo gallery in WordPress without a plugin?

Use the core Gallery block. Add it to a post or page, choose images from the Media Library or upload new ones, and set columns, cropping and links in the sidebar. It creates a responsive grid that works with most themes.

How do I add a lightbox to a WordPress gallery?

Recent WordPress versions include an expand-on-click option for images that opens a larger view in an overlay. On older versions, set the gallery to link to the media file and install a lightbox plugin, or use a page builder gallery with a built-in lightbox.

How do I reorder images in a WordPress gallery?

Select an image inside the Gallery block and use the move arrows or drag handle in its toolbar to shift it left or right. You can also open List View and drag the Image blocks into a new order within the gallery.

Why are my gallery images different sizes?

Crop images to fit is probably turned off, so each image keeps its original shape. Turn the setting on in the Gallery block sidebar to make all images the same size, or upload images with matching proportions.

How many images can a WordPress gallery have?

There is no fixed limit in the Gallery block, but very large galleries slow pages down. For dozens or hundreds of photos, split them across several pages or use a gallery plugin with albums and pagination.

Sources

  1. Gallery Block WordPress.org Documentation
  2. gallery_shortcode() WordPress Developer Resources
  3. An alt Decision Tree W3C Web Accessibility Initiative
  4. Browser-level image lazy loading web.dev
  5. FooGallery WordPress.org

Is your product missing, or something out of date?

Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.

About the editors

Written and checked byWPLegible Editorial Team Independent WordPress reviews and guides

Researched from the primary sources listed above and checked against our editorial rules before publishing.