Archives for custom posts

hello,
ive registered two custom post types in the custom.php file. one called property_sales and one called property_rentals.
as per my last site i see the best way to display a page of these is to use an archive page,

my question is would I then just call this file archive-property_sales.php (or rentals) and is the path to it simply www.mysite/property_sales? as I can’t seem to find it to put it in the menu.

Scratch that, I found i needed to use the slug, but I have still not fathomed out what page template its using?

i have created two pages, one called archive-sales.php and one called archive-rentals.php and placed them both in the root, but when I go to mysite/sales or mysite/rentals I am getting an archive but its not using the template I have made. am I missing something?

The template hierarchy recognises archive-{$post_type}.php; whereas you appear to be using archive-{$slug}.php. Correct it and you should be fine.

@Foxaii Yep thank you! -
the url uses the slug, but the template uses the post_type, another thing learned today!
it’s working now! - just fathomed it a second before i read this.

I’m stuck on the same problem. I’m using super-CPT to create custom post types. Here is an example:

$areas = new Super_Custom_Post_Type( 'area', 'Área', 'Áreas', $register = array(
        'supports' => array( 'title', 'editor'),
        ) 
  );

Then I created file called archive-area.php and paste index.php content.

But when I try to acess mysite.com/area, the page is not found.

1 Like

Did you visit your Settings > Permalinks page in the dashboard?

1 Like

Solved. Thanks enollo.

1 Like