WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

in archive.php file, I want to know, which type of archive I i'm in. For example, if I i'm in archive for category Personal I'd like to be able to display it in header of the archive. Of course, I can create file like category-12.php, category-13.php ... and then harcode it in the file, but it doesn't seem to be very good example of code reuse. Thanks for answers.

share|improve this question
up vote 1 down vote accepted

Inspect get_queried_object().

On an archive for the category Uncategorized you get something like …

stdClass Object
    [term_id] => 1
    [name] => Uncategorized
    [slug] => uncategorized
    [term_group] => 0
    [term_taxonomy_id] => 1
    [taxonomy] => category
    [description] => 
    [parent] => 0
    [count] => 8
    [cat_ID] => 1
    [category_count] => 8
    [category_description] => 
    [cat_name] => Uncategorized
    [category_nicename] => uncategorized
    [category_parent] => 0

… and on an archive for the tag test

stdClass Object
    [term_id] => 18
    [name] => test
    [slug] => test-2
    [term_group] => 0
    [term_taxonomy_id] => 18
    [taxonomy] => post_tag
    [description] => 
    [parent] => 0
    [count] => 1

So you can test if a property taxonomy for that object exists and what the value is. Then adjust your template.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.