I’m trying to come up with a solution for a photography site I am working on using WP.
Here’s what I’m up to:
1) I have a Gallery page, with lots of different sub-pages.
2) Each of these sub-pages is a gallery.
3) For example the New York sub-page will show all posts with a category name of New York.
4) I want to use only ONE page template for each of these gallery sub-pages. So I need a way to dynamically show all posts with a category name equal to the name of the sub-page that is showing those posts.
Does that make sense? Maybe there’s a better way of going about this? Custom fields? Bottom line is I don’t want to have to create a new page template every time a new photo gallery is added.
The following piece of code worked for me, displaying all posts from category three, but of course means that I will have to create a new page template each time I want to add a photo gallery. Not ideal.
Template Name: gallerypage
< ?php query_posts('cat=3&showposts=10'); if (have_posts()) : while (have_posts()) : the_post(); ?>