Title: Gallery&#8217;s look differs when dynamically created with shortcode
Last modified: March 3, 2020

---

# Gallery’s look differs when dynamically created with shortcode

 *  [frogi16](https://wordpress.org/support/users/frogi16/)
 * (@frogi16)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/gallerys-look-differs-when-dynamically-created-with-shortcode/)
 * I wanted to create a page where in one column I will have automatically generated
   list of all galleries in an album. Click would show selected gallery in the second
   column.
 * Code is pretty simple:
 *     ```
       jQuery(document).ready(function($) {
       	function createLink(text_content, shortcode)
       	{
       		var inputElement = document.createElement('a');
       		inputElement.textContent = text_content;
       		inputElement.addEventListener('click', function(){
       			document.getElementById("gallery-field").innerHTML = shortcode;
       		});
   
       		return inputElement;
       	}
   
       	var list = document.createElement('ul');
   
       	for(var i = 0; i < my_script_data.galleries_count; ++i)
       	{
       		var element = document.createElement('li');
       		var link = createLink(my_script_data.galleries[i]['title'], my_script_data.galleries[i]['shortcode']);
       		element.appendChild(link);
       		list.appendChild(element);
       	}
   
       	document.getElementById("menu-column").firstElementChild.firstElementChild.appendChild(list);
   
       	if(my_script_data.galleries_count)
       	{
       		document.getElementById("gallery-field").innerHTML = my_script_data.galleries[0]['shortcode'];
       	}
       });
       ```
   
 * As you can see I set initial shortcode exactly as I would set any other. This
   code relies on data prepared by .php file. Shortcode generation looks like this:
   `
   $galleries[$ordinal]['shortcode'] = do_shortcode('[ngg src="galleries" ids="'.
   $galleryid . '" display="basic_thumbnail" thumbnail_crop="0"]');`
 * It seems to be working, all galleries from the album are available to choose 
   and gallery in second column changes in regard to chosen element of list. But
   gallery view which opens after clicking any of the images in gallery is different
   at the beginning and after using any of links. First gallery has buttons to go
   to the next and previous images, number of images in the gallery displayed in
   the corner etc. If I choose any gallery from my list (even the same one as initial!)
   everything looks perfectly normal at the beginning. Gallery in the second column
   changes, but selecting the thumbnail displays only very basic view of one image,
   as if it wasn’t linked to the gallery. There is no buttons or any info about 
   gallery. Even background is slightly different.
 * I wonder why it happens and what could I do to ensure that all of my galleries
   will be displayed properly. Right now it seems that any dynamic changes cause
   problems.
    -  This topic was modified 6 years, 3 months ago by [frogi16](https://wordpress.org/support/users/frogi16/).
    -  This topic was modified 6 years, 3 months ago by [frogi16](https://wordpress.org/support/users/frogi16/).

Viewing 1 replies (of 1 total)

 *  [gabyimagely](https://wordpress.org/support/users/gabyimagely/)
 * (@gabyimagely)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/gallerys-look-differs-when-dynamically-created-with-shortcode/#post-12512559)
 * We are deeply sorry, but this thread is a custom code question, and it’s out 
   of our support scope

Viewing 1 replies (of 1 total)

The topic ‘Gallery’s look differs when dynamically created with shortcode’ 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/)

 * 1 reply
 * 2 participants
 * Last reply from: [gabyimagely](https://wordpress.org/support/users/gabyimagely/)
 * Last activity: [6 years, 3 months ago](https://wordpress.org/support/topic/gallerys-look-differs-when-dynamically-created-with-shortcode/#post-12512559)
 * Status: not a support question