WordPress.org

Ready to get started?Download WordPress

Forums

Custom Category Templates
[resolved] WordPress supports this functionality natively (13 posts)

  1. Ian Dunn
    Member
    Posted 1 year ago #

    You don't need a plugin to set assign templates to categories. You can just create category-{$slug}.php files. See the Template Hierarchy page for more details.

    http://wordpress.org/extend/plugins/custom-category-templates/

  2. h8every1
    Member
    Posted 1 year ago #

    And what if you want to use the same template on several categories?
    Say, 4 categories of 20 on the site? WP doesn't support this.

  3. Ian Dunn
    Member
    Posted 1 year ago #

    Sure it does :)

    Just setup something like this in category.php

    $currentCategory = get_query_var( 'cat' );
    $fruitCategories = array( 'apples', 'oranges', 'bananas' );
    $vegitableCategories = array( 'tomatoes', 'peppers', 'carrots' );
    
    if( in_array( $currentCategory, $fruitCategories ) )
        require_once( 'category-fruit.php' );
    elseif( in_array( $currentCategory, $vegitableCategories ) )
        require_once( 'category-vegitables.php' );
  4. shazdeh
    Member
    Plugin Author

    Posted 1 year ago #

    Same goes for custom page templates, so why WP supports that? :)
    I think the main point is that with this plugin you can ship custom templates for category views, and let the theme user choose one. That snippet above does not allow for that. Also, it's a lot simpler with this plugin than to code it by hand which is really hard for some people ;)

  5. kilakiwi
    Member
    Posted 1 year ago #

    @Ian, I have searched everywhere for this solution! Thank you for taking the time to post it.

  6. thomasgafo
    Member
    Posted 1 year ago #

    Please can I have more detail, step by step on how to customized a category page? For instance I want to have an image at the top of a category page before having the posts below. like Basile BOLI blog for instance at here: http://www.africatopsports.com/actu/basile-boli-2/

  7. kilakiwi
    Member
    Posted 1 year ago #

    @thomasgafo, I am using the Rich Tax Description Editor plugin to customize my category pages. It allows you to add images and formatted text to your category description. Make sure that you theme options are set to show category descriptions. (Some themes don't display category descriptions, and in that case you would need to edit your theme, so that descriptions are displayed.)

  8. thomasgafo
    Member
    Posted 1 year ago #

    Please I am using arras theme. and this is the website. http://www.africatopsports.com

  9. kilakiwi
    Member
    Posted 1 year ago #

    Install and activate the plugin I mentioned. You will see that your category description area now has a rich text editor that looks similar to your post editor. You can add images to your category descriptions and format the text in the same manner that you with your posts. The description will be displayed at the top of your category page along with any images that you added.

    I believe that the Arras theme does support category descriptions, so if your descriptions are not shown at the top of your category pages after you add them using the plugin, ask in the Arras forum how to enable them.

  10. thomasgafo
    Member
    Posted 1 year ago #

    Unfortunely they can not be shown.

  11. thomasgafo
    Member
    Posted 1 year ago #

    Thank you very much KILAKIWI. This code: "<div class="catdesc"><?php echo category_description( $category ); ?></div>" help me out.

  12. kilakiwi
    Member
    Posted 1 year ago #

    That's great, Thomas! Glad to hear it.

  13. thomasgafo
    Member
    Posted 1 year ago #

    Hello, I hope you are fine
    Please I would like to have an idea about this and if possible the solution. Is it possible tomake a background image clickable?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.