• Resolved CrispySinger

    (@crispysinger)


    I’m currently using “content-single.php” to display the content from a pod I have created for my website. Due to this, it now means that when a Post is loaded certain elements on the page that were to be filled by a Pod are now empty with no content showing. I’m planning to use Pods to extend the default Posts module so I would like to keep “content-single.php” purely for that page alone in the end to avoid confusion due to not sharing the same layout and or content being shown.

    What I’m trying to do is set it up so that whenever I click on a page that is going to use Pods, it then uses its own page to display the content rather than using “content-single.php” if that makes sense.

    Any help or tips would be greatly appreciated.

    Cheers

    https://wordpress.org/plugins/pods/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Josh Pollock

    (@shelob9)

    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/

    Thread Starter CrispySinger

    (@crispysinger)

    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.

    Thread Starter CrispySinger

    (@crispysinger)

    Analysing it a bit more, I think I understand it now. Will test something and see if it works.

    Plugin Contributor Josh Pollock

    (@shelob9)

    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.

    Thread Starter CrispySinger

    (@crispysinger)

    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!

    Plugin Contributor Josh Pollock

    (@shelob9)

    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.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Pods – A unique page for each Pod.’ is closed to new replies.