WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How do I assign a specific template to just one category. (12 posts)

  1. jonniboo
    Member
    Posted 4 years ago #

    Hi,
    I am trying to use the 'monochrome' theme for a certain category with ID=3.
    Not sure how to create category-3.php and where to place it.

    Am new to WP so please be clear :)

    Thanks.

  2. syncbox
    Member
    Posted 4 years ago #

    A "theme" is not assigned to just one page. It's a directory with a style sheet and accompanying files that are used to display the database content USING either index.php, page.php, category.php or single.php based on the type of content (Page Post vs. Category Post(s)).

    If you mean creating that custom category.php file, you simply name the file after the category ID of the category you want to have use it. So, if your category is 9, then the file name would be category-9.php and would be uploaded right in with the other files in the theme you are using. All other categories will use either category.php (if there IS one) or index.php (which HAS to be there).

    Does that make more sense to you? Let me know if you need more help!

  3. syncbox
    Member
    Posted 4 years ago #

    BTW, if you need to get the ID of a category, you can get into your admin and go to Posts>Categories and hover over the desired category in the list. You should see the ID# in the status bar at the bottom of the browser window.... something like edit&cat_ID=#

  4. jonniboo
    Member
    Posted 4 years ago #

    Hi,

    I'm not sure which file to use in order to create category-3.php (for ID=3). Have tried it by copying and renaming both the archive and the index php files but hasn't worked.

  5. esmi
    Forum Moderator
    Posted 4 years ago #

    If you don't have a pre-existing category.php file in your theme, use a copy of archive.php, rename it to category-3.php and then start customising it.

    Remember to press CTRL and F5 simultaneously when viewing an updated page/site. Or try emptying your browser cache. This should ensure that your web browser fetches a fresh copy of the page rather than serving up an out-dated copy from your own cache.

  6. jonniboo
    Member
    Posted 4 years ago #

    Hi,

    Have both copying and renaming archive.php to category-3.php in the 'monochrome' theme folder, but it hasn't worked.

    Any ideas why?

  7. MichaelH
    Member
    Posted 4 years ago #

    Works fine for me...so once you copy archive.php to category-3.php are you making changes to category-3.php so you can distinguish that display from other categories that are displayed with archive.php?

    Related:
    Template Hierarchy
    Stepping Into Templates

  8. jonniboo
    Member
    Posted 4 years ago #

    Its a different theme from the rest of the site, I'm using the default theme at the moment for the site, and the monochrome theme just for category-3, so I'm expecting to see changes applied to just this category.
    Or is there another step I need to do?

  9. MichaelH
    Member
    Posted 4 years ago #

    You would need to create the category-3.php in the wp-content/themes/default folder then.

    Also remember, when a WordPress core update happens, changes to the files in the wp-content/themes/default folder will be overwritten with a new set of files.

    Related:
    http://www.google.com/search?q=wordpress+different+themes+for+different+categories

  10. jonniboo
    Member
    Posted 4 years ago #

    Hve just renamed the archive in default theme to category-3 but doesn't make any difference.

  11. MichaelH
    Member
    Posted 4 years ago #

    You are using the WordPress Default theme for everything but category 3 posts. You want to display category ID 3 posts using a 'look' that is that of the Monochrome theme.

    You will need to customize the category-3.php to be the look you want. It will take some work to make that look like the 'Mmonochrome' theme.

    Please review Category_Templates and review some of the articles here:
    http://www.google.com/search?q=wordpress+different+themes+for+different+categories

  12. jonniboo
    Member
    Posted 4 years ago #

    Thanks for the advice Michael. I'll check the articles.

Topic Closed

This topic has been closed to new replies.

About this Topic