Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have set up a custom post type and a custom taxonomy for it. I'm using the latest version of Wordpress. I believe I should be using the is_post_type_archive function, but this seems to be is returning false no matter what.

The post type I've set up is called articles and the taxonomy is called editions

I'm trying to access /editions/september and the archive page is showing, but the page title is showing as the first post's title. I can fix this if I can figure out how to write a conditional if statement to let me know I am in a custom post type custom taxonomy page. How can I achieve that?

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

Have you made sure your CPT is using the 'has_archive' => true, parameter? And try something like;

wp_reset_query(); 

 if (is_post_type_archive('articles')){
     // do something
    }
share|improve this answer
add comment

Following @Wyck, make sure has_archive is set to true while registering your post type. As stated in codex for is_archive, this will also work:

is_archive('book'); //book is a cpt

is_archive(array( 'newspaper', 'forum' )); //multiple cpts
share|improve this answer
add comment

Your Answer

 
discard

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.