WordPress.org

Ready to get started?Download WordPress

Forums

Customise Category pages (9 posts)

  1. krushinfo
    Member
    Posted 7 years ago #

    Hi,

    Is it possible to customise the words and images on each individual category page?

    i.e. /category/books/ would have 'Welcome to the books area' with a picture of a book.

    Anyone know how to do this?

  2. moshu
    Member
    Posted 7 years ago #

    You may want to take a look at the Category Templates:
    http://codex.wordpress.org/Category_Templates

  3. krushinfo
    Member
    Posted 7 years ago #

    it seems complicated, i assume i have to make these files and put them in the /theme/ directory

    category-1.php
    category-2.php
    category-3.php
    category-4.php
    category-5.php
    category-6.php
    category-7.php

    And then, above the loop in those files add:

    <div id="sticky-snip">
    This is the 'Books' category, enjoy the book reviews.
    </div>

    Doesn't seem *that* complicated if the above is correct!

    Awesome.

  4. moshu
    Member
    Posted 7 years ago #

    Basically that's the idea.
    Of course, if the differences are not too big... you could have one category.php template and seven if/else if conditional statements for displaying a different title/text.

  5. dzr
    Member
    Posted 7 years ago #

    That's exactly what you could do, and no it isn't complicated, but it might be overkill. In the default theme (Kubrick) that comes with WordPress look at wp-content/themes/default/sidebar.php which uses conditional tags (is_foo()) to print things like "You are browsing the archives for the bar category". Look at the codex for conditional_tags. If you just want some custom stuff in your sidebar, or before the loop on your archives I think conditional tags might be even easier.

    Best, Darren

  6. ryoken
    Member
    Posted 7 years ago #

    Yes, but that solution does seem somewhat ugly. Perhaps there is a template tag for it?

    edit: yup, use http://codex.wordpress.org/Template_Tags/single_cat_title at the top of category.php

  7. krushinfo
    Member
    Posted 7 years ago #

    ryoken, that is a nice quick solution that i will use for the time being.. thing is i need an image as well....

    i'll look into the conditional tags but i'll probably end up trying the first solution.

    will post the results

  8. krushinfo
    Member
    Posted 7 years ago #

    Hi, one last question.. can I customise the single.php page depending on what category it is from?

    i.e.
    single-1.php
    single-2.php
    single-3.php
    single-4.php
    single-5.php
    single-6.php
    single-7.php

    ? :S

  9. moshu
    Member
    Posted 7 years ago #

    Not as you described above!
    You need a plugin:
    http://guff.szub.net/2005/07/21/post-templates-by-category/

    Please, read carefully the whole page I linked to - there is a mention about another useful plugin, too.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags