php - Pods - display link to relationship post -
i'm using pods set custom post types in wordpress.
i have 2 custom post types: car , garage. in car have set relationship field garage, when editing car post can select 1 of garage posts available drop-down.
when viewing car post, display name , link garage post selected. how that?
below example http://pods.io/tutorials/get-values-from-a-custom-relationship-field
//get pods object current post $pod = pods( 'pod_name', get_the_id() ); //get value relationship field $related = $pod->field( 'relationship_field' ); //loop through related field, creating links own pages //only if there loop through if ( ! empty( $related ) ) { foreach ( $related $rel ) { //get id related post , put in id //for advanced content types use $id = $rel[ 'id' ]; $id = $rel[ 'id' ]; //show related post name link echo '<a href="'.get_permalink($id).'">'.get_the_title( $id ).'</a>'; //get value some_field in related post , echo } //end of foreach } //endif ! empty ( $related ) instead of permalink garage post, i'm getting several permalinks car post i'm viewing.
any ideas?
Comments
Post a Comment