0

I have created one custom post type lets say movie, now I have created 4 posts under movie type.

Slugs are movie/parasite/director and movie/parasite/actor. Similarly movie/joker/director and movie/joker/actor. Now I want to load two types of template one for director and other for actor based on slug.

I'm using pod plugin for custom post type.

What I'm doing I have created one single php file name single-movie.php file under theme folder. This single-movie.php file template file is loading for all movie post type but I want to load different template based on movie post type slug. Any help appreciated.

4
  • 1
    I'm sorry but most of the normal solutions will work for you since you are using the Pods plugin. Additionally, your directors and actors should not be the same post type if you intend them to behave differently. You need Pods help, not WordPress help – Tom J Nowell Jan 16 at 19:35
  • I'd attempt to tackle this in a single template and just change the output based on the slug, but that's IF I hadn't already made them different post types as Tom J. Nowell suggested, however, I know next to nothing about pods. Is it too late to separate the post types? – Tony Djukic Jan 16 at 20:43
  • @TomJNowell there should be some solutions from WordPress. What if I'm not using pod then same scenario. – Johne Doe Jan 17 at 5:52
  • All the solutions I can think of involve changing register_post_type parameters which you don't use because you use Pods. Pods help and other 3rd party plugin dev support is off topic here. The only generic solution that might work is to admit that you actually have 2 post types not 1 and split them rather than trying to bundle them into one, or to move to register_post_type and abandon pods – Tom J Nowell Jan 17 at 10:43
1

In this case, since there's a many-to-many relationship between movies and actors, I recommend making them two separate pods with a relationship between them. See the intro video at https://pods.io/ ... I don't remember where he explains relationship fields but it's all in there.

You don't need to use PHP if you don't want to. You could use Pods templates (see the video). Something like this for movies (it's a tweak of one of mine). It assumes you've filled in the title and content for both movies and actors:

    <div>
      [if related_actors]
        <h4 style="font-weight:bold; font-size:x-large;">Actors:</h4>
        <div style="padding-left:4em;">
          [each related_actors]
            <h3>
              [if post_thumbnail_url]
                <img src="{@post_thumbnail_url.small}" style="float:left; width:150px; height:auto; padding-right: 15px;">
              [/if]
              {@post_title}
            </h3>
            <div style="clear:both;">{@post_content}</div>
          [/each]
        </div>
      [/if]
    </div>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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