I am working on a WordPress theme that was made by someone before me. The website is for a band, and if you want to see the releases of the band the URL is in this format:
www.domain.com/band/[bandname]/releases/
I am now trying to make a subsection with details of each release. The links from the overview of releases now works, and when the users click the link they get to the URL:
www.domain.com/band/releases/[name-of-release]
The releases are custom post types created with “More Types”, and the child content are made with fake pages. A template seems to be loaded based on the slug/page the user is visiting. This is for the ‘releases’ page:
if ($current == 'releases') {
get_template_part( 'single', 'band-releases' );
}
I have made a template for showing an individual release as well, but how can I get template based on its slug as it will be dynamic (several releases)?
If it’s a custom post type, the template that displays the individual releases (www.domain.com/releases/[name-of-release]) is single.php.
The template single.php will also be used to display all individual posts. If you want a template that is just for the releases, create a file called single-releases.php (https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post).
If you name your templates properly, WP will know which template goes with which content.