How to limit the number of gallery items in a page

Normally gallery shortcode displays all the gallery items which are added to that gallery. If you want to limit the number of gallery items in a page, you should edit some codes.

1) Go to Plugins->Editor

2) Select “Dysania Grid Gallery” plugin

3) Open “gridbox.php” file

4) Edit the codes like on the following screenshot;

Screenshot_1

Edited code block will look like the following (Be very careful during editing codes. If you miss a single comma,quote etc. you will get an error);

    extract(shortcode_atts(array(
		"id" => 'id',
        "columns" => 'columns',
        "resolution" => 'resolution',
        "maxitem" => 'maxitem'
	), $atts));
                global $post;
                        $loop = new WP_Query(array('post_type' => 'dysania_grid', 'meta_key' => 'dysania_filterselect','meta_value' =>  $id ,'posts_per_page' => $maxitem));

5) Click “Update File” button

6) Now you should add a new attribute into your gallery shortcode (maxitem=”4″) like the following. If you don’t add this attribute, your gallery shortcodes will not work properly;

[gridgallery id="153" maxitem="4"]

You can change 4 with any other number. In this example gallery will display maximum 4 gallery items.

If you don’t want to limit the number of gallery items, you can use a big number like 99.