Use One Archive Template for All Custom Post Type Archives

If you have created multiple custom post types, you can use the same archive-cpt.php template.

By default, you don’t need to create a archive.php template for your custom post type as WordPress will use the standard archive.php file.

If you want to use a unique archive-cpt.php template which is different to what your standard post type uses, you can.

Rather than create a archive-cpt file for each custom post type, simply add this PHP code to your functions file.

Change the example custom post types in the code, portfolio and community to the names of your custom post types and separate them using a comma.

The code above also assumes your custom post type archive file is named archive-cpt.php and resides in the root directory of your theme folder.

Was This Tutorial Helpful?

Free

$0

Access only to all free tutorials per month.



Monthly

$75

Access to 10 premium tutorials per month.


Tutorial Request


Includes code guarantee and coding support.

Yearly

$500

Access to 15 premium tutorials per month.


Monthly Tutorial Request


Includes code guarantee and priority coding support.