8

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?

1 Answer 1

10

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

6
  • 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? Commented Jun 20, 2011 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 Commented Jun 20, 2011 at 22:50
  • haha we were typing at the same time! Commented Jun 20, 2011 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... :-( Commented Jun 20, 2011 at 22:53
  • glad to be of help.. kinfa reminds me of when i was messing around with a user role mod for 3 days (went almost bald) and then someone kindly pointed out i spelt contributer wrong...hahah Commented Jun 20, 2011 at 22:55

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.