Support » Themes and Templates » Can I create a custom post type archive template that has a page as a parent?

  • Can I create a custom post type archive template that has a page as a parent?

    The main hierarchy I’m looking to create would be: domain.com/community{is page}/gallery{is archive}/post-name{is single}

    My current register_post_type declaration works for single posts but not for the archive which results in a 404 error:

    add_action( 'init', 'create_post_type' );
    function create_post_type() {
       register_post_type( 'gallery',
          array(
             'labels' => array(
                'name' => __( 'Gallery' ),
                'singular_name' => __( 'Gallery' )
             ),
             'public' => true,
             'has_archive' => true,
             'rewrite' => array(
                'slug' => 'gallery'
             )
          )
       );
    }

    Surely there has to be a way to create a custom post type that doesn’t live at the root level of the site hierarchy.

    Any help would be greatly appreciated!

    Brad

  • The topic ‘Can I create a custom post type archive template that has a page as a parent?’ is closed to new replies.