Title: Replace ngg shortcode value using a function
Last modified: November 26, 2023

---

# Replace ngg shortcode value using a function

 *  Resolved [gamerwithadegree](https://wordpress.org/support/users/gamerwithadegree/)
 * (@gamerwithadegree)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/replace-ngg-shortcode-value-using-a-function/)
 * Hi,
 * I currently insert galleries into a ACF WYSWYG field using the following shortcode:
 * [ngg src=”galleries” ids=”202″ display=”basic_thumbnail” images_per_page=”20″]
 * The gallery is then displayed on a separate page created using WordPress endpoint.
 * However, I would like to also display the gallery images on the main post page
   but with less images per page. I already have hundreds of galleries so pasting
   a new shortcode with a new images_per_page value into a new ACF field ins’t an
   option.
 * I have tried a few methods using shortcode_atts and [shortcode_atts_{$shortcode}](https://developer.wordpress.org/reference/hooks/shortcode_atts_shortcode/)
   but I can’t seem to get the images_per_page value to change.
 * Do you know of a realiable way to essentially alter the images_per_page attribute
   and change it using PHP? I want to be able to set the number of images per page
   to 6 for every gallery dislayed ont he main post page. And have the original 
   amount displayed on the page created suing the endpoint?
 * I hope this makes sense adn thanks for your help.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Contributor [Imagely](https://wordpress.org/support/users/imagely/)
 * (@imagely)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/replace-ngg-shortcode-value-using-a-function/#post-17232570)
 * Hi [@gamerwithadegree](https://wordpress.org/support/users/gamerwithadegree/),
 * We are sorry, but, unfortunately, it doesn’t look like NGG has such a filter 
   at this time and **shortcode_atts_ngg **wouldn’t help much in programmatically
   changing **images_per_page **attribute specifically.
 * The good news is that we look forward into allowing an action in one of the future
   NGG versions that should enable passing values for the shortcode attributes like
   in the example from below:
 * add_action( ‘ngg_displayed_gallery_construct’, function ( $displayed_gallery ){
   
   if ( is_archive() ) { $displayed_gallery->display_settings[‘images_per_page’]
   = 6; }} );
    -  This reply was modified 2 years, 6 months ago by [Imagely](https://wordpress.org/support/users/imagely/).
    -  This reply was modified 2 years, 6 months ago by [Imagely](https://wordpress.org/support/users/imagely/).
 *  Thread Starter [gamerwithadegree](https://wordpress.org/support/users/gamerwithadegree/)
 * (@gamerwithadegree)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/replace-ngg-shortcode-value-using-a-function/#post-17243599)
 * Hi, Thank you so much for your reply I am glad you are adding the add_action.
   Can you tell me which version this will be in? I noticed 2 updates to NGG recently,
   just wondering if it is in one of them.
 * Thank you.
 *  [Mihai Ceban](https://wordpress.org/support/users/mihaiimagely/)
 * (@mihaiimagely)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/replace-ngg-shortcode-value-using-a-function/#post-17256934)
 * Hi [@gamerwithadegree](https://wordpress.org/support/users/gamerwithadegree/),
 * Thanks for asking us. You can use the add_action with NGG 3.50 and newer versions.
    -  This reply was modified 2 years, 6 months ago by [Mihai Ceban](https://wordpress.org/support/users/mihaiimagely/).

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Replace ngg shortcode value using a function’ is closed to new replies.

 * ![](https://ps.w.org/nextgen-gallery/assets/icon-256x256.png?rev=2083961)
 * [Photo Gallery, Sliders, Proofing and Themes - NextGEN Gallery](https://wordpress.org/plugins/nextgen-gallery/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/nextgen-gallery/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/nextgen-gallery/)
 * [Active Topics](https://wordpress.org/support/plugin/nextgen-gallery/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/nextgen-gallery/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/nextgen-gallery/reviews/)

 * 3 replies
 * 3 participants
 * Last reply from: [Mihai Ceban](https://wordpress.org/support/users/mihaiimagely/)
 * Last activity: [2 years, 6 months ago](https://wordpress.org/support/topic/replace-ngg-shortcode-value-using-a-function/#post-17256934)
 * Status: resolved