• Resolved paa1605

    (@paa1605)


    Hey guys.

    Im using wordpress to create a site that sells sports equipment. I have some top level pages such as golf, basketball, soccer etc. Each of these has sub pages, and sub sub pages. Golf for example, has golf>clubs>putters. Basketball has basketball>balls>indoor. Each post is a product review and is assigned a category that reflects the page structure. For example, a callaway putter would be assigned to the category golf>clubs>putters. What im trying to do is show these posts on the correct pages based on their assigned category. How do i do this?

    The main problem im having is that i dont want to create an individual page template for each category and sub category as i’ll end up with hundreds of page templates all doing the same thing. Am i correct in thinking that the best course of action is to create one page template for handling all top level category archives, and one for sub category and then one for sub sub category? If so can anyone help in writing the code?

    Thanks, patrick

Viewing 6 replies - 1 through 6 (of 6 total)
  • I don’t know if this will help, but take a look at bluegrassmiataclub.com, especially the Good Stuff->Good Eats categories.

    Each of the lowest level categories (e.g. All American) is assigned to a unique page. On that page is a Custom Field named ‘category-to-show’ whose value is the name of the category. All pages call the same template which interrogates the Custom Field and loads posts belonging to that category.

    @paa1605 Look into custom post types as using it will create labels in your admin like you have pages and posts and then can add your content in respective post types.
    There is plugin Custom Post Types UI check it out see if that will work for you.

    Thread Starter paa1605

    (@paa1605)

    Thanks for the reply guys. I tried using custom post types for my main categories eg golf, basketball, and then creating custom taxonomies for the sub categories, however i ran into major problems with the permalink settings and couldn’t find a way to fix the problem.

    I think that using custom post types just complicates the issue because you give up some of the built-in WordPress functionality.

    Did you look at the site link I provided? I think it is doing something very close to what you want.

    Thread Starter paa1605

    (@paa1605)

    I looked at the site link and yes your right, it is very close to what i’m after. I see that all the lowest level categories ie. all american, barbeque, international etc, all display their content based on a template page. This is exactly what i want for my site, as all sub level pages such as golf/clubs and basketball/balls will look the same, as well as sub sub pages such as golf/clubs/putters and basketball/balls/indoor. Creating a page template that queries accordingly and then displays the correct posts is what i’m after, i’m just not sure what i should be querying? Do you have any ideas? Thanks.

    Each of the lowest level categories (e.g. All American) is assigned to a unique page. On that page is a Custom Field named ‘category-to-show’ whose value is the name of the category. All pages call the same template which interrogates the Custom Field and loads posts belonging to that category.

    On each page that displays a single category there is a Custom Field with the name of the category. The template gets the Custom Field and displays the category it names.

    One difference that I see in what you describe and what I am doing is that only the lowest categeory (sub-sub level) is displayed. The higher levels don’t have their own pages. This means that you can only get to the sub-sub template through a menu choice, not by selecting a category from a higher level.

    Email me at mac =at= mcdspot =dot= com and I will mail you a copy of the template that I use.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Page template for multiple pages?’ is closed to new replies.