custom post type archive page url to point to Page permalink

You have multiple options here.

1. Define post type archive slug on post type registration

By setting 'has_archive' => 'galleries' you can define custom post type archive slug.
Check documentation.
Then you can delete your page “galleries” then add & customize the archive-post_type.php

2. Disable default archive for post type

Disable the archive by setting 'has_archive' => false then keep the page for the post type archive.

3. Redirect archive requests to your page

You can permanent redirect default archive request to your page.

function archive_to_custom_archive() {
    if( is_post_type_archive( 'post_slug' ) ) {
        wp_redirect( home_url( '/galleries/' ), 301 );
        exit();
    }
}
add_action( 'template_redirect', 'archive_to_custom_archive' );

I will say the first method is good!

Leave a Comment