Skip Navigation

[Resolved] Show custom fields from a related post

This support ticket is created 3 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 2 replies, has 2 voices.

Last updated by alexanderS-9 3 years, 5 months ago.

Assisted by: Shane.

Author
Posts
#2079245

This is basically a follow-up question to my last ticket. I have the post reference field "tarif" referring to a CPT named honorar. In this CPT I have custom fields like hourly, weekly, monthly, and I want to show those values.

<tr>
<td>Tarif</td>
<td><?php $tarif = types_render_field( "tarif" ); $title = get_the_title($tarif); echo ucwords ($title); ?></td>
</tr>

This works fine now thanks to Christians help. But now I would like to also show for example

<tr>
<td>Stunde</td>
<td><?php $hourly = types_render_field( "hourly" ); echo ucwords ($hourly); ?></td>
</tr>

The thing I need help with please is how to query that, seeing it is in a referenced CPT and not the one I am currently in.

I was thinking maybe something like this? But I cannot make it work right now.

$post = $tarif;
setup_postdata( $post );

I hope I could explain well enough what I am trying to do. Thanks for the help.

#2079415

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Alexander,

You can simply do this.

<td><?php $hourly = types_render_field( "hourly", array( 'item' => $tarif ) ); echo ucwords ($hourly); ?></td>

This should give you the value from the post in the $tarif variable.

Please let me know if this helps.
Thanks,
Shane

#2080201

My issue is resolved now. Thank you!