WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Category and sub-category templates (3 posts)

  1. hinch
    Member
    Posted 6 years ago #

    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?

  2. stvwlf
    Member
    Posted 6 years ago #

    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

  3. hinch
    Member
    Posted 6 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic