Create a Photo Album Gallery in WordPress without a Plugin

Photo Album

The previous gallery in WordPress was using with a lighbox effect. The users wanted to create a photo gallery organizing by monthly albums. However, in this article we will make you able to create a photo album gallery in WordPress without any plugin – Create a Photo Album Gallery in WordPress without a Plugin

Before starting, lets some points to be cleared. Whenever a user is clicking on the album page, they will see an archive in grid display where each album starts with different cover and all the photos in it. So this was the idea to have one album per month. In case any user clicks on the photo, so they will be taken to the single photo page. They can see there the title of the photo without any hesitation.

How you will make it?

All the required features can be done using the built in WordPress functionality. It is easy to treat each monthly album as a post, so each album could be having a single page with some info. The information is including background information etc and each image will treat as an attachment. You are able to use the default posts or you are also having a blog then this need to be created in a custom post type.

Tips to create a Photo Album Gallery

In the first step, you should have to create a site-specific plugin or a project specific plugin.

In case you want to use Custom Post Types for your projects, then you need to produce codes and paste it in your specific plugin.

Next, you need to register additional image sizes in WordPress for the grid display for example;

1 add_image_size (‘album-grid’, 225, 150, true);

After the additional image size, we are going to show you how to add some additional fields to the Media Uploader. It will make you able to add Photographer’s names, URLs and related info while you are uploading each image.

Tips for adding additional fields to WordPress Media Uploader

Once it finished, let’s move to add some albums, so upload all the images you want to attach to that album. After that attach a particular cover photo and set it as a featured image. The background info can be added in the content area of the post.

In the backend few albums are left, so you put the code to display it.

Now you will create a template file that is called archive-albums.php. You have to paste the header codes, footer codes, sidebar and other design elements you want. After that create a post loop and we will display all attachment from a post inside the loop. However, the thumbnail that will link to the single image page won’t be displayed.

<li class=”album-grid”><a href=”<?php the_permalink(); ?>” title=”<?php the_title(); ?>”><?php the_post_thumbnail(‘album-grid’); ?></a></li><?php if ( $post->post_type == ‘albums’ && $post->post_status == ‘publish’ ) {
$attachments = get_posts( array(
‘post_type’ => ‘attachment’,
‘posts_per_page’ => -1,
‘post_parent’ => $post->ID,
‘exclude’ => get_post_thumbnail_id()
) );

if ( $attachments ) {
foreach ( $attachments as $attachment ) {
$class = “post-attachment mime-” . sanitize_title( $attachment->post_mime_type );
$title = wp_get_attachment_link( $attachment->ID, ‘album-grid’, true );
echo ‘<li class=”‘ . $class . ‘ album-grid”>’ . $title . ‘</li>’;


The main CSS style that the most people are getting worry for is the class. Album-grid

.album-grid{width: 225px; height: 150px; float: left; list-style: none; list-style-type: none; margin: 0 18px 30px0px;}

Well, this would allow each image replacing in the grid and you could get the style whatever you want. Next, you need to do is to create a single-attachment template. This is the page where the user is taking to, so they can view each individual image. Here you will see the image title, photographer’s name and photographer’s URL.

Now the last point is left in the list is to create an individual albums page. Let me clear it to you that your custom post type is called albums. You need to create a single-albums.php file. Then try to copy all the header, footer, sidebar and more design elements that you want to have.

Element do the same in the loop as we did with the archive albums template. You must add the album and title description before you add the featured image and attachment grid. You need to add code for this that is here below;

<h1><?php the_title(); ?></h1>
<div class=”entry-content”><?php the_content(); ?></div>

//Insert grid code below this line

Finally, these are the tips for creating a photo album gallery in WordPress without a plug in. We hope that this article will provide you more help. For further information you visit to our website at WWW.INTERNETSEEKHO.COM