galleryshortcode. 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.
- 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.
- Assign all galleries that you wish to appear on your custom page to this category.
- Now you will need to create a custom page template to display all galleries in this category on one page. Copy the file named
photography_protheme 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.
- 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.
- 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' ) ); ?>
- 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.
- 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”.
- 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.
- 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.