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 a custom post type, called 'job', and I have the following templates in my theme:

  • single-job.php (works fine, displays single job as expected)

  • archives-job.php (is not recognized?)

  • archives-current.php (also not recognized)

  • archives.php (is not recognized either?)

  • index.php (archives page uses this page)

Here is how I've registered my custom content type in functions.php:

add_action( 'init', 'create_jobs' );
function create_jobs() {
  $labels = array(
    'name' => _x('Jobs', 'post type general name'),
    'singular_name' => _x('Job', 'post type singular name'),
    'add_new' => _x('Add New', 'Job'),
    'add_new_item' => __('Add New Job'),
    'edit_item' => __('Edit Job'),
    'new_item' => __('New Job'),
    'view_item' => __('View Job'),
    'search_items' => __('Search Jobs'),
    'not_found' =>  __('No Jobs found'),
    'not_found_in_trash' => __('No Jobs found in Trash'),
    'parent_item_colon' => ''
  );

  $supports = array('title', 'editor', 'custom-fields', 'revisions', 'excerpt');

  register_post_type( 'Job',
    array(
      'labels' => $labels,
      'public' => true,
      'has_archive' => 'current', 
      'supports' => $supports
    )
  );
}

When i go to the url http://mywebsite/wordpress/current/, it displays all of my jobs as expected-- but it is not using ANY of the archive templates, and instead uses index.php.

My understanding of the wordpress documentation was that it would look for archives-(special archive for post type name).php, then archives-(post type).php, then archives.php, then index.php... but it just goes straight to index.php?

I did visit the permalinks settings page and clicked save to refresh everything, so I'm not getting 404's, it's just not outputting to the correct templates... did I name them incorrectly? Is there a registration setting I missed when I created my custom post type?

share|improve this question
add comment

1 Answer 1

up vote 6 down vote accepted

try 'has_archive' => 'true'; and do the permalink reset before testing! and it should be singular archive-job.php rather than archives-job.php

share|improve this answer
    
I tried what you said, but changing has_archive's value from 'current' to true means I won't get the URL i want for the archive: mysite.com/wordpress/current... what url would i access the archives for a custom post type without specifying it? –  Sarah Jean Jun 20 '11 at 22:46
    
you may not even have to bother with the 'has_archive' => 'true'; as i see your not using a rewrite, just try the file rename from plural to single first –  MartinJJ Jun 20 '11 at 22:50
    
haha we were typing at the same time! –  Sarah Jean Jun 20 '11 at 22:51
    
i will try that thanks!! –  Sarah Jean Jun 20 '11 at 22:51
    
IT WORKED!!!! Man I feel dumb. Brilliant, if I had the reputation to upvote your answer, I would, but alas, reputation does not transfer from other stack exchange sites... :-( –  Sarah Jean Jun 20 '11 at 22:53
show 2 more comments

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.