Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #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
    Sean

    #1401125

    Hi Support,

    Kindly just chasing this topic up, do you have a solution to the above?

    Thanks
    Sean

    #1401371

    Resolved myself, to remove the conflict, set has_archive to false and you can maintain the slug by keeping ‘rewrite’ => array(‘slug’ => ‘careers’) as is.

    #1401604

    Hi,
    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

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Custom post type archive page conflict’ is closed to new replies.