Reputation: 3146
When we want to get some relation field we do
$pod = pods( 'pod_name', get_the_id() );
$related = $pod->field( 'relationship_field' );
and I get list of results array 1, 2 ...
but I need to get relationship_field
where name="some_name"
. How can I do that?
Upvotes: 0
Views: 467
Reputation: 30071
The following will retrieve the related field named relationship_field
if the related post has a title equal to some_name
:
$pod = pods('pod_name', get_the_ID());
$params = array(
'WHERE' => "relationship_field.post_title = 'some_name'",
);
$related = $pod->find($params);
Upvotes: 1
Reputation: 987
You're example was right, but with a minor tweak this will be more useful as an example:
// get the pod record based on current post ID
$pod = pods( 'pod_name', get_the_ID() );
$params = array(
// be sure to sanitize the value going in, if it's dynamic
'where' => 'relationship_field.post_title = "Some title"'
);
// find records that match $params
$pod->find( $params );
// loop through records found
while ( $pod->fetch() ) {
// do something with $pod->field( 'field_name' )
// or $pod->display( 'field_name' )
}
Upvotes: 0