‘has_archive’ => false — and You’re Free to Play as You Want!

What does this parameter in a CPT mean?


$this->args = [ ... 'has_archive' => false, ... ]

Have you ever thought about this, or faced similar challenges?

Many WordPress developers still rely on Archive-CPT Templates, but if you are working with FSE and clean HTML templates in Gutenberg, as well as implementing multilanguage support using different aliases (specific slugs) for different languages, it will be much easier to use separate Pages with custom templates for archive lists.

Let’s try it…

    ],
            'public'             => true,
            'publicly_queryable' => true,
            'show_ui'            => true,
            'show_in_menu'       => true,
            'query_var'          => true,
            'rewrite'            => ['slug' => 'services'],
            'capability_type'    => 'post',
            'has_archive'        => false,
            'hierarchical'       => false,
            'menu_position'      => null,
            'menu_icon'          => 'dashicons-hammer',
            'supports'           => ['title', 'editor', 'thumbnail', 'excerpt', 'comments', 'custom-fields'],
            'show_in_rest'       => true,
            'taxonomies'         => ['post_tag'],
        ];

With 'has_archive' => false, you can create a Page with the same slug — "services" — instead of using the default archive-services.html template.

You can experiment and adjust it as you like. Try it out — and enjoy your development!