WordPress.org

Ready to get started?Download WordPress

Forums

Can I create a custom post type archive template that has a page as a parent? (1 post)

  1. bradwiatr
    Member
    Posted 2 years ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Topic