Tagged: advanced layout builder, ALB, archive, CPT, Custom Post Type
-
AuthorPosts
-
March 10, 2023 at 4:05 pm #1400724
Hi Support,
I have created a custom post type by placing the relevant code in my functions.php file:
// Our custom post type function function create_posttype() { register_post_type( 'careers', // CPT Options array( 'labels' => array( 'name' => __( 'Careers' ), 'singular_name' => __( 'Job' ) ), 'public' => true, 'has_archive' => true, 'rewrite' => array('slug' => 'careers'), 'show_in_rest' => true, 'taxonomies' => array( 'category' ), ) ); } // Hooking up our function to theme setup add_action( 'init', 'create_posttype' );
I created an Advanced Layout Builder page with the slug /careers but that layout isn’t being presented at that URL because the custom post type is pulling the archive.php page by default?
A few methods I have thought of to resolve this issue:
1. Rename my slug in my custom post type from “careers” to “jobs”, I believe that would allow my ALB careers page to display but the URLs for the jobs would be “/jobs/job-single-page” rather than “/careers/job-single-page” which isn’t great.
2. Create an “archive-careers.php” template, my worry with this approach is I won’t be able to get it to look as good as my page which uses ALB.
Is there a way to tell the careers slug to not use archive.php and look at the ALB careers page? or what approach would you recommend?
Thanks
SeanMarch 14, 2023 at 10:48 am #1401125Hi Support,
Kindly just chasing this topic up, do you have a solution to the above?
Thanks
SeanMarch 16, 2023 at 1:17 pm #1401371Resolved myself, to remove the conflict, set has_archive to false and you can maintain the slug by keeping ‘rewrite’ => array(‘slug’ => ‘careers’) as is.
March 18, 2023 at 3:40 pm #1401604Hi,
Glad to hear that you have this sorted out, and thanks for sharing your solution. If you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.Best regards,
Mike -
AuthorPosts
- The topic ‘Custom post type archive page conflict’ is closed to new replies.