SAVE 25% when you purchase our Theme Bundle and Make Plus together. View bundle deal.

Adding extra gallery pages to Photography

By Drew Strojny on March 17, 2011

Update November 8, 2011 Extra gallery pages are now possible using the gallery shortcode. If you’re running Photography 1.4 or later, you do not need to make the changes in this tutorial – see your theme documentation for instructions on creating multiple gallery pages.

With the release of Photography 1.2 the Gallery post type now includes built-in support for categories. Why is this useful? By default Photography shows all your galleries on one “Gallery Page”. With category support you may now create new gallery pages that only show galleries associated with a specific category. Our newest forum moderator, Mike Fields, wrote up an awesome tutorial on how to do just that. Thanks Mike! Before you get started, be sure to read through this tutorial: Customizing your theme → Editing a template file.

  1. Create a new category and give it a name representative of the collection of galleries that you would like to create. I’ll be using “Nature Shots” as an example, but the name you use can be anything you like.
  2. Assign all galleries that you wish to appear on your custom page to this category.
  3. Now you will need to create a custom page template to display all galleries in this category on one page. Copy the file named gallery.php from the photography_pro theme folder into your PRO child theme folder. You will want to rename it as well. If the category you created has the title “Nature Shots”, I would suggest naming the template gallery-nature-shots.php. It’s a good practice to use only lowercase letters and the dash character (-) when naming files. Never use spaces.
  4. Next you will need to change the name of the page template you just created. The template name is located at the top of the file and looks like this:
    /*
    Template Name: Gallery
    */
    

    You will want to give it a name that is similar to the name of the category you created in the first step. If the category was “Nature Shots”, I would suggest something like this:

    Did you know that Surf Office, Postmatic, Yeah Dave, and over 700,000 small businesses run their websites with Make, our free WordPress page builder. Discover the Make page builder now.

    /*
    Template Name: Nature Shots Gallery
    */
    

    It’s a good practice not to use any punctuation here. Just use letters and spaces for best results.

  5. Now you will need to adjust the query. The original query is located on line 8 and looks like this:
    <?php query_posts( 'post_type=gallery&orderby=menu_order&nopaging=true&order=ASC' ); ?>

    you will want to replace this line with the following code:

    <?php
    query_posts( array(
    'post_type'     => 'gallery',
    'orderby'       => 'menu_order',
    'nopaging'      => 'true',
    'order'         => 'ASC',
    'category_name' => 'Nature Shots'
    ) );
    ?>
    
  6. Save your changes and upload the new page template to your server (if it isn’t already there). If you’re confused about uploading a file be sure to watch the video tutorial on how to use an FTP client.
  7. Create a new page in WordPress by expanding the “Pages” tab in the admin menu and clicking the “Add New” link. Be sure to give the page a title similar to the category name. I used “Nature Shots”.
  8. On the right-hand side of the screen, you should see a meta box with the heading “Page Attributes”. You will want to select the page template we just created from the “Template” dropdown. If you do not see this box, you will want to click the “Screen Options” tab (located in the upper right of the screen) and make sure that the “Page Attributes” option is checked.
  9. Publish your page! Now add the new page to your menu via Appearance → Menus. When you visit the page you should see only the galleries that have been associated with the “Nature Shots” category.

Enjoyed this tutorial? Let us know in the comments. If you have any questions or problems please head over to the support forums and we’ll be happy to help you out.

Enjoy this post? Read more like it in Tutorials.

8 Comments

  1. matt cram

    This is a great addition however is there not a way to show a gallery category without a custom page?

  2. Drew Strojny

    Right now there is not an option, but that is a good idea. We will take a look at possibly adding a default category template or possibly using a new taxonomy in an upcoming version of the theme.

  3. Matt Cram

    How about another custom post type for gallery with just a few meta boxes to choose which category? I am not sure if a custom post type can use templates or not though so this might lock us into one template but it would allow multiple galleries from the admin.

  4. Matt Cram

    I should have said another custom post type for albums which would be a collection of galleries. (the theme currently calls a collection of images a gallery and has a custom post type for that already… but you knew that)

  5. Pen Hunt

    Great theme Drew! I purchased your shelf theme last week but on WordPress. Is there an advantage buying your themes (that are available on WordPress.com) on your site? I think themes on your site have to have WordPress installed. Do you provide help installing it? And what version of WordPress do your themes use?

  6. JaM2

    Hi, How to change thumb position in gallery change (single gallery post date change does not work – the last published gallery is always last in main page

Comments are closed.