Apply template by path/slug related to custom post type?

You can’t set a project as a base of permalink because you would have to enter rewrite rules for each one.

What you can do is create a custom taxonomy related-resources:

function wpse_287202_related_resources_taxonomy() {

    $labels = array(
       ...
    );

    $args = array(
        'labels'                     => $labels,
        'hierarchical'               => true,
        'public'                     => true,
        'show_ui'                    => true,
        'show_admin_column'          => true,
        'show_in_nav_menus'          => true,
        'show_tagcloud'              => true,
    );
    register_taxonomy( 'related-resources', array( 'product', 'post', 'page' ), $args );

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

It needs to be associated with your product custom post type and posts, pages or other custom post types you want to add to related resources. You do that by changing the second parameter of register_taxonomy.

In your product custom post type add related-resources to taxonomies:

'taxonomies' => array( 'related-resources' ),

Now when you edit project add “Amazing Project 17” to related resources taxonomy the same way as you would add a category and check it just for the project it relates to. In this setup, you can’t have a project be a related resource to other project but that could be changed.

In every post, page or custom post type other than project you associated with the taxonomy, you can select “Amazing Project 17” and it will be displayed as a related resource for that particular project.


Now you need to display it all and to know what template to use check WP Hierarchy. Related resources will be displayed using taxonomy-related-resources.php file. There just make sure to exclude project from displaying as it is part of the related resources taxonomy, do it by checking get_post_type().

To display link to related resources on the project page use:

$term = get_the_terms( $post->ID, 'related-resources' )[0];
echo '<a href="' . esc_url( get_term_link( $term, 'related-resources' ) ) . '">' . __( 'Related Resoucrces', 'text_domain' ) . '</a>';

If things seem confusing read more about custom taxonomies and how they can be used with custom post types.