Written on January 28, 2009 by  /  with 8 comments  /  in the Wordpress Tips category.

Placing NextGEN in Your WordPress Theme with PHP

Needing some guidance with your SEO strategy? Hire my SEO Consulting services today! Call me @ (801) 899-3527 - Click here

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.

8 responses to this article so far...

Leave a comment