I’m presuming that “content-single.php” is a template part included using get_template_part()
in either “single.php” or “index.php” in your theme. If so, am I right that you’re asking how to include a different template part for a custom post type Pod versus the included Posts post type?
Here is an example of how to include a different template part for a custom post type, post, or page: https://gist.github.com/Shelob9/176f9b6bf98ac8f44e83
Alternatively, use entirely different templates for the different post type. Here is a helpful chart for understanding which template is used when showing different content
http://www.chipbennett.net/themes/template-hierarchy/
Yeah, it’s basically what every Post uses as a template. At the moment the page is set up so that it will grab the content for the desired pod based on the URL which was clicked on.
<?php
//get the current slug
$slug = pods_v( 'last', 'url' );
//get pods object
$mypod = pods( 'case_study', $slug );
// set our variables
$name= $mypod->field('title');
$location= $mypod->field('location');
$cont= $mypod->field('content');
$gallery= do_shortcode( $mypod->display('gallery') );
$image= $mypod->display('image');
$quote= $mypod->field('quote');
$subtext= $mypod->field('sub_text');
$permalink= $mypod->field('permalink');
?>
This works for any Pod dependant pages but obviously when loading a post or the likes the post content shows but the layout for the Pod content still shows, just with no content there.
I tried adding the code from the example to that page and when done it grabs the content through for a Post that has been clicked on, by this part I assume get_template_part( 'content', $part );
.
Does that code need to go on the/each custom post template file, or would I need to add it elsewhere?
P.S. Using Roots and building my own theme, if that helps about the structure of default files etc.
Cheers.
Analysing it a bit more, I think I understand it now. Will test something and see if it works.
I’m glad this makes sense to you. I can’t say that I understand how Roots works, so I don’t know where it would be best to use this code. It’s goal is to route based on content type to the right template part. Not sure if that makes sense with how Roots works, as I don’t know Roots.
Sorry for the very late reply, been busy with work.
Got it working in the end, turns out it was a case of adding “-podname” after the “single.php” file for each Pod I wanted to display. I.e. “single-clients.php”
I tried doing that at the start but due to editing the wrong file I assumed it wasn’t working. After I realised how the files were pulled together it all made sense.
Thanks for the assistance!
I’m glad to see that you got this worked out. Please let us know if there is anything else we can do to help.