Documentation, Reference Materials and Tutorials for Envira Gallery
Have you ever wanted to limit images inside a gallery to show only a certain number of images? For example, you can show only 4 images from a gallery that has over 150 images simply by editing the shortcode. Let’s take a look at this document to figure out how!
Modifying the Shortcode
First, we need add a shortcode for our gallery to our post or page. You can easily add a gallery shortcode to your page by inserting the shortcode from the Add Gallery button that appears on every page and post from your site.
In our case, we added the following shortcode to our visual editor:
Next, we will need to modify our shortcode. We’re going to add some additional text to the shortcode to limit the number of images from the gallery like so:
[envira-gallery id="131" limit="4"]
As you can see above, all that’s needed to complete the last step is to add the limit option.
As a result of adding that limit option to the shortcode, we have effectively limited the number of images that will show from the gallery to 4.
Q: Why don’t I see all the images from the gallery in the lightbox?
A: Because you are limiting the number of images in the gallery, the modified shortcode will only show that number of images in the lightbox as well.