WordPress.org

Ready to get started?Download WordPress

Forums

Multiple themes: How to divert single.php to different category themes? (7 posts)

  1. websta
    Member
    Posted 6 years ago #

    Background: I am re-designing the default theme (Kubrick) in WP 2.2 as a CMS. It has 9 primary categories and over 200 (sub-)categories.

    To aid in navigation, each primary category has its own, color-coordinated, header.php and sidebar.php. Consequently, I have 9 header.php files and 9 sidebar.php files. Site thus far is available at: http://www.growandknow.com . The bulk of the content will be Posts, due to the need of the categories.

    Question: I would like single.php to include the sidebar and for single.php to display the appropriate header and sidebar from one of the nine primary categories.

    How is that done?

    It wasn't too difficult to figure out how to divert users to 1-of-the-9 category.php files, but I have no clue on where/how the single.php files are called for, and how to tie the various category themes to single.php.

  2. moshu
    Member
    Posted 6 years ago #

    With a little search you could have found this - it has been suggested as a solution 2 days ago (again):
    http://guff.szub.net/2005/07/21/post-templates-by-category/

  3. websta
    Member
    Posted 6 years ago #

    Moshu, Thanks for the response. I have implemented that plugin already to create the various sub-themes of my site, and tie them to the various major categories.

    However, even with the plugin, I still only get a default "single post" page -- not one of the several themes. Since the entire site would likely be viewed via single post pages, this would likely be confusing for users.

    I assume that I need to make 9 variations of single.php to accommodate this...? Where is single.php is called for? How do I get WP to make that call for a single-post-page divert to the different themes?

  4. Omarvelous
    Member
    Posted 6 years ago #

    One possibility....

    Plug the category in the body html element as a class....

    Then through css, make the changes accordingliy when body contains category1 class...

    That's a thought...

  5. websta
    Member
    Posted 6 years ago #

    Thanks, Omarvelous. I guess I would need a more detailed info. I am concerned about messing up the "post templates by category" plugin. I have read the following documentation, but I still can't figure it out, so maybe I'm just ignorant/retarded:

    http://codex.wordpress.org/Template_Hierarchy
    Template Hierarchy

    http://codex.wordpress.org/Template_Tags/query_posts
    Template Tags & query posts

    http://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_Query#Query_based_on_Custom_Field_and_Category
    Query based on Custom Field and Category

    http://wordpress.org/support/topic/38046?replies=53
    Display by Category home.php template

    http://codex.wordpress.org/Category_Templates#Further_Reading
    Category Templates: Introduction

    http://wordpress.org/support/topic/121011
    Displaying Posts Using a Custom Select Query

    http://codex.wordpress.org/Stepping_Into_Templates
    Stepping into Templates

    http://codex.wordpress.org/The_Loop
    The Loop

    http://codex.wordpress.org/Theme_Development
    Theme Development

    http://codex.wordpress.org/Glossary#Query_string
    Query string

    http://codex.wordpress.org/Query_Overview
    Query Overview

  6. sito
    Member
    Posted 6 years ago #

    Hi,

    Even though this is 6 months (too) late, I hope it can still be useful. I just found this myself.

    http://www.webdesignerwall.com/tutorials/wordpress-theme-hacks/

    Look under "unique single template". I think you won't even need to use the "post templates by category" plugin after that!

  7. buckyboog
    Member
    Posted 6 years ago #

    I'm having the same problem, I have different single-14.php, single-15.php, single-16.php, templates with a single.php that directs them appropriately...

    I have a post in categories 14, 15, and 16... I want to show the appropriate template based on what category someone is viewing..

    so website.com/14/the-post
    would pull up a different template than

    website.com/16/the-post

    This is not the case, website.com/16/the-post and website.com/15/the-post always pull up with first category and template, in this example website.com/14/the-post

Topic Closed

This topic has been closed to new replies.

About this Topic