Many of you are probably familiar with the popular Wordpress plugin NextGEN Photo Gallery. It’s one of the most highly downloaded and highly used plugins for Wordpress. With it you can create Albums and Galleries and place those Albums and Galleries inside your blog posts or blog pages. A widget also comes with the plugin that allows you to easily add a sidebar widget that displays your most recent photos/images from your galleries. But what if you need more control over where and how your photos are displayed within your Wordpress theme? I found 3 very useful customizations that I have used consistently on many blogs I have worked on and the PHP code to make it happen.
I Want To Display The 6 or So Most Recent Images On a Page
Let’s say you want to display a certain amount of your most recent images on a page, and not in your sidebar using the widget that comes with the plugin. Here’s some PHP that you can place in your template, and then just use some CSS skills to style it how you please!
As you can see with the code, the first number parameter in this case “3″ specifies the exact amount of recent images you want to display. While the following two numbers represent the height and the width of the images. Play around with it and get the desired look you are after!
I Want To Show Images From a Specific Gallery Or Album On a Page
This code will be a little bit different, since you are wanting to pull images from a specific Gallery or Album form NextGEN. Here is really the most simplest way of accomplishing this. Inside the template file where you wish to place your code use this…
As you can see in the code, “Gallery” specifies that you want to pull images from a Gallery. You can swith this to “Album” and it will put an entire album rather than just a Gallery. The number “1″ is the ID for the Gallery or Album. You can find this by hovering over your Gallery or Album links in the backend of Wordpress.
One important thing to note with this PHP call. I have not found anything that allows you to specify how many images you want to pull from a gallery. So what I have done is specify the number of images shown before pagination in the NextGEN plugin options in the backend. A workaround in this area would be helpful and i’ll be sure to post it when I find it.
- Digg this post
- Bookmark this post on del.icio.us
- Stumble this post
- Mention on Facebook









Great, thanks for this code! You’re the man!
In example 1 i have changed the parts that say “Recent” into “Random” to get Random Pictures displayed anywhere i want – which is exactly what i was looking for.
Bookmarked your blog and “thumbs up” in Stumbleupon
Have a good time!
Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you!
This is exactly what I was looking for!
I can’t seem to get this working, I’ve tied both codes.
thanks allot man!
I’m also looking for a way to display x amount of pics from gallery y!
Thank You!! Now its almost i got it all.. please check my 1st time wordpress setup..: http://www.hgffdavao.org/
does anyone know how to use nggDisplayRecentImages but link to the gallery page the image is from rather than open it in lightbox?
it seems i cant see any php code you are talking about