0

I will describe here steps I made to make my galleries for my first WP theme. I wanted to have a few links in my menu which will take user to page with thumbnails. Each thumbnail takes user to gallery with bunch of horizontally displayed images.

First, in my functions.php file I've added new size for my icons:

add_image_size( 'wide-image-icon', 200, 150, true );

Then, I've made my template file for gallery category (lets call it Gallery1) and category "Gallery1". In my gallery1.php template file I used query for posts with galleries:

query_posts(array('category_name'=>'Gallery1','posts_per_page'=>-1))

Then, in posts loop I've displayed my gallery icons (which are featured images of posts):

the_post_thumbnail('wide-image-icon');

So now, after creating new page with "Gallery1" template, I can add post, select "Gallery1" category for it, add pictures using standard "Insert gallery", choose one as featured image and I'm good to go.

The problem is that's not universal way of doing this. What if I would like to make another gallery page (Gallery2). Then I need to make new template file, create new category, change category name in query inside template file, add new page with this template attached to it. How do you do it?

I'd also like to ask about some admin side improvements for gallery. I've seen themes where there was a completely new tab inside admin area where you saw all galleries, you could easily change images order, add/remove galleries etc. Right now on my website I add my news ( I use the same system here ), galleries, blog posts and normal pages like "Bio" as posts only which is definitely not good.

PS. Any articles, video tutorials, books or tips and tricks are welcome.

@edit: How can I manage display of my galleries on admin side? I'd like to remove whole editor and leave just pictures if you know what I mean.

1 Answer 1

3

This is all sorts of wrong, you need to first decide if you want to use posts, pages or custom post types.

You alluded at the end that you wanted a new tab like you have seen in some themes, this would be the right way to do it using Custom Post Types.

You can learn how to create them here,
http://codex.wordpress.org/Post_Types#Custom_Types
http://codex.wordpress.org/Function_Reference/register_post_type

After that you can create a template file for your post type that is specific to how you want it to look. For instance say you created a CPT called "Gallery", your theme file can be single-gallery.php. There you can use the loop anyway you want to display and style your photos, and every post made in this post type (Gallery) will use that theme file.


To answer your second question, when you register a new custom post type there are parameters, one of them can enable or disable the editor. The one your looking for is supports --> 'editor'

By default to manage the post's photos you click on Add Photo--->Gallery--> there you find the management options. If you want to customize a new photo management "console" you will have to make another question as it would be to complicated to go into details here, I have seen them but I'm not entirely sure what the best method is to accomplish this.

4
  • Cool, thank You for teeling me about CPT. And how can I manage display of this post type on admin side? I'd like to remove whole editor and leave just pictures if you know what I mean.
    – smogg
    Aug 11, 2011 at 10:35
  • @smogg "And how can I manage display of this post type on admin side? I'd like to remove whole editor and leave just pictures if you know what I mean." You should add this question to your original question, so that it can be answered properly. Aug 11, 2011 at 14:28
  • @Chip Bennett Yeah, sorry. Already done.
    – smogg
    Aug 11, 2011 at 14:31
  • @Wyck Second part of your answer is about exactly what I want to achieve, I will ask second question then, thanks.
    – smogg
    Aug 11, 2011 at 16:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.