Reputation: 303
I am using Pods plugin for the first time, i have created 2 pods: Movies and Producers, i have a relationship field in the movies pod for the producers and i want to display all movies produced by a certain producer, i tried this shortcode:
[pods name="movie" where="producer.meta-value = 'clark spencer' template="Movie template"]
on the template i used this:
<h1>{@movietitle}</h1> <br/>
<h3>{@producer}</h3>
<img src="{@movieposter}">
but it's not working it displays all movies rather than filtering by producer's name. Any idea how to filter movies using where clause?
Upvotes: 2
Views: 4318
Reputation: 303
After some digging i've found the correct shortcode i'm not sure what went wrong maybe it's because of the double quotes or the spaces but this shortcode worked for me:
[pods name="movie" where= ' producer.post_title= "clark spencer" ' template="Mov"]
Upvotes: 0
Reputation: 1
if get this right producer is you relationship field in the movie CPT/Pod? And is this a Bi-directional relation? And the Name of the Producer is the post_title? Producer itself links to the "full entry" of a producer so you are missing in which field (e.g producer.post_title ) that where should search
anyway it's easier to use
[pods name="producer" where="post_title.meta-value = 'clark spencer' template="Movie template"]
And as Template:
<div>
<h3>{@post_title}</h3> //which field from Producer do you Want to show?
[if movies]
[each movies] //loops through all related movies from the producer
<h1>{@movietitle}</h1>
<img src="{@movieposter}">
[/each]
[/if
</div>
That being said i'm not sure it's a good idea to hardcode a search, although depending on your use case maybe read - https://meta.stackoverflow.com/questions/66377/what-is-the-xy-problem and rephrase your question.
The Video has an example of displaying related stuff! More Information&Video: http://pods.io/docs/build/template-tags-in-pods-templates/
Upvotes: 0