I want to get current title at file archive.php

My code :

if ( is_category() ){ 
    echo "CATEGORY";
} else if( is_tag() ){ 
    echo "TAGS"; 
} else if( is_author() ){ 
    echo "AUTHOR"; 
} else if( is_tax() ){ 
    echo "TAXONOMY"; 
} else { 
    echo "ARCHIVE"; 

Is there a way to simplify this ? I try this, but didn't work:

if ( is_post_type_archive() ) {

There was a new function introduced in Wordpress 4.1 called the_archive_title() which does just that. You can simply add the_archive_title() in your archive page.

If you need to filter the output, see my answer here on how to accomplish that

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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