CPT: archive-cpt.php VS custom page template

I’ve created a CPT named portfolio. Now i want to create a page which will act as an INDEX for this CPT. Now i’ve two choices ….

a) Make a custom template having custom WP_Query. In this way i can assign this template to any page and that page will work as an index.

b) Make archive-portfolio.php instead, which will act as an INDEX.

Now i’ve a few questions …

1: Which is the correct approach?

2: If (a) then what is the actual usage of archive-cpt.php page then?

3: If (b) is correct approach, is there any possibility to make this page available in wordpress menu manager by default and also in the drop down menu (located at Setting->Reading) to use it as front page?

1 Answer
1

The correct way is latter one – correctly configure your CPT registration to have post type archive and use appropriate template file for it.

However it gets tricker with your additional requirements.

Exposing post type archives to be used in menus is significantly requested/explored topic, but I don’t think it made it into core yet. There are mutiple solutions floating around, from quick search I have Post Type Archive Link plugin for it bookmarked.

Front page stuff is very convoluted. It’s probably doable but unlikely to be smooth and will probably take some pre_get_posts tinkering and possibly overriding template hierarchy logic around there.

Leave a Comment