WordPress.org

Support

Support » Themes and Templates » [Resolved] Category and sub-category templates

[Resolved] Category and sub-category templates

  • I want my main category and sub categories to be displayed differently. Ideally I’d like to edit archive.php with a simple conditional statement. My link structure is like this:

    /blog/category/*category*/*sub-category*/

    So I’ve been trying to make a conditional statement like this:

    if (isset(*sub-category*)) {
    }
    else {
    }

    I have been trying to get values get_query_var but no luck yet.

    Is this possible?

Viewing 2 replies - 1 through 2 (of 2 total)
  • try

    if ( is_category(‘ *subcategory ‘ ) ) {

    } elseif ( is_category(‘ *subcategory ‘ ) ) {

    } else {

    }

    *subcategory* can be either the category number, the category slug, or the category name

    there is also in_category () which is useful in some cases

    Thanks, I have used is_category to include a different template.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Category and sub-category templates’ is closed to new replies.