関係フィールドを取得したい場合は、
$pod = pods( 'pod_name', get_the_id() );
$related = $pod->field( 'relationship_field' );
そして、結果配列 1, 2 のリストを取得します ... しかし、relationship_field
whereを取得する必要がありname="some_name"
ます。どうやってやるの?
relationship_field
以下は、関連する投稿のタイトルが に等しい場合、named の関連フィールドを取得しますsome_name
。
$pod = pods('pod_name', get_the_ID());
$params = array(
'WHERE' => "relationship_field.post_title = 'some_name'",
);
$related = $pod->find($params);
あなたの例は正しかったですが、微調整すると、これは例としてより便利になります:
// 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' )
}