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

On the default post type, why does the has_archive property equals to FALSE?

$type_obj = get_post_type_object('post');
var_dump($type_obj->has_archive); // FALSE
share|improve this question
Because it doesn't make sense to have archive for posts. FALSE is set by default to all post types. – Eugene Manuilov Jun 6 '12 at 12:00
Posts have archives, they are displayed on the homepage with a fresh install. – bpierre Jun 6 '12 at 12:31
has_archive Enables post type archives. Will use $post_type as archive slug by default. Default: false Note: Will generate the proper rewrite rules if rewrite is enabled. Also use rewrite to change the slug used. It means that there should be archive with slug http:://mysite.com/post/ - do you have such archive? – Eugene Manuilov Jun 6 '12 at 12:49
Got it, has_archive should have been named has_archive_slug. Thank you. – bpierre Jun 6 '12 at 12:57
up vote 2 down vote accepted

Late answer.

has_archive applies only for the rewrite arguments.

In Detail

If has_archive is set to true, then the $archive_slug will get set to the rewrite['slug'] argument. If then a rewrite['with_front'] arg is set, then this one will get prepended. The result of this will then get added as rewrite rule:

add_rewrite_rule( "{$archive_slug}/?$", "index.php?post_type=$post_type", 'top' );

If feeds are set to true and has_archive also, then you'll also get rewritten rules for feeds:

add_rewrite_rule( "{$archive_slug}/feed/$feeds/?$", "index.php?post_type=$post_type" . '&feed=$matches[1]', 'top' );
add_rewrite_rule( "{$archive_slug}/$feeds/?$", "index.php?post_type=$post_type" . '&feed=$matches[1]', 'top' );

The same principle applies for rewrite['pages']:

add_rewrite_rule( "{$archive_slug}/{$wp_rewrite->pagination_base}/([0-9]{1,})/?$", "index.php?post_type=$post_type" . '&paged=$matches[1]', 'top' );

Summed up:

If you ain't got has_archive set to true, then any try to add rewrites for feeds, pages or archives will end up with a big ?.

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.