1

I'm looking to create multiple pages from one custom post type. For example, I have a custom post type called "Students" that collects various pieces of information, such as name, email, phone, bio, and resume for each student.

In addition to creating a template for the Student post type, I need to auto-generate subpages with custom fields from the custom post type. The overall hierarchy would be like:

  • Student (top level page, mysite.com/students-name)
    • Bio (i.e., mysite.com/students-name/bio)
    • Resume (i.e., mysite.com/students-name/resume)
    • Contact (i.e., mysite.com/students-name/contact)

After building these templates, adding a new student should autogenerate any of the above pages.

I've explored two options, neither of which seem great:

  1. Use subsites - for the minimal amount of information being gathered, subsites seem like major overkill and would not scale well if given hundreds of students (8-9 DB tables per subsite would be thousands of tables)
  2. Use hierarchical custom post types - this also seems to have scaling issues, as the subpages would need to be duplicated for each student. This makes scaling much harder.

Is there any insight on the best way to go about this?

2
  • Alternatively, you could accomplish this with query parameters, although the template file might get long depending on how different the subpages are from each other (e.g. mysite.com/students-name?bio).
    – YourManDan
    Aug 16, 2023 at 14:04
  • What specific scaling issues are you referring to with the hierarchical CPT? There shouldn't really be technical limitations if the code and hosting and done properly, but it may not be a great UX. Assuming you mean UX, you could use a single post, and have multiple editor input fields, or meta boxes for the bio, resume, etc. You could then use rewrite rules to make all of the URLs point to the same post, and some template logic to display the content that corresponds to the URL.
    – Ian Dunn
    Aug 16, 2023 at 15:47

1 Answer 1

0

Could you create taxonomies for the "Student" custom post type for "Bio," "Resume," and "Contact"?

// Register Custom Taxonomy
function create_bio_taxonomy() {

    $labels = array(
        'name'                       => _x( 'Bios', 'Taxonomy General Name', 'text_domain' ),
        'singular_name'              => _x( 'Bio', 'Taxonomy Singular Name', 'text_domain' ),
        'menu_name'                  => __( 'Bio', 'text_domain' ),
        'all_items'                  => __( 'All Bios', 'text_domain' ),
        'parent_item'                => __( 'Parent Item', 'text_domain' ),
        'parent_item_colon'          => __( 'Parent Item:', 'text_domain' ),
        'new_item_name'              => __( 'New Bio Name', 'text_domain' ),
        'add_new_item'               => __( 'Add New Bio', 'text_domain' ),
        'edit_item'                  => __( 'Edit Bio', 'text_domain' ),
        'update_item'                => __( 'Update Bio', 'text_domain' ),
        'view_item'                  => __( 'View Bio', 'text_domain' ),
        'separate_items_with_commas' => __( 'Separate bios with commas', 'text_domain' ),
        'add_or_remove_items'        => __( 'Add or remove bios', 'text_domain' ),
        'choose_from_most_used'      => __( 'Choose from the most used', 'text_domain' ),
        'popular_items'              => __( 'Popular Bios', 'text_domain' ),
        'search_items'               => __( 'Search Bios', 'text_domain' ),
        'not_found'                  => __( 'Not Found', 'text_domain' ),
        'no_terms'                   => __( 'No Bios', 'text_domain' ),
        'items_list'                 => __( 'Bios list', 'text_domain' ),
        'items_list_navigation'      => __( 'Bios list navigation', 'text_domain' ),
    );
    $args = array(
        'labels'                     => $labels,
        'hierarchical'               => false,
        'public'                     => true,
        'show_ui'                    => true,
        'show_admin_column'          => true,
        'show_in_nav_menus'          => true,
        'show_tagcloud'              => true,
    );
    register_taxonomy( 'bio', array( 'student' ), $args );

}
add_action( 'init', 'create_bio_taxonomy', 0 );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.