0

関係フィールドを取得したい場合は、

$pod = pods( 'pod_name', get_the_id() );
$related = $pod->field( 'relationship_field' );

そして、結果配列 1, 2 のリストを取得します ... しかし、relationship_fieldwhereを取得する必要がありname="some_name"ます。どうやってやるの?

4

2 に答える 2

1

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);
于 2014-01-20T11:00:59.407 に答える
0

あなたの例は正しかったですが、微調整すると、これは例としてより便利になります:

// 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' )
}
于 2014-01-24T14:04:01.173 に答える