Skip Navigation

[Resolved] Displaying Other CPT Fields in Single View for a CPT

This thread is resolved. Here is a description of the problem and solution.

Problem:

The issue here is that the user wanted to display a custom field value from another post.

Solution:

So our custom fields shortcodes takes an ID attribute as a parameter and what you can do is to pass the ID of that post into the shortcode and it should display the value of the field from that post.

This support ticket is created 6 years, 6 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 Eric 6 years, 5 months ago.

Assisted by: Shane.

Author
Posts
#918850
single-listing-view.gif
content-template-module.gif

I created a content template for a single view of a custom post type called "listings." Within the content template, I successfully added the post title of another custom post type called "agents." Under the "agent" post type results, I need to add the results of two custom fields that belong to the "agent." The two fields are "agent phone" and "agent email." How do I do this? I've tried but the single listing will not display the phone number and email that belongs to the agent.

Thanks in advance.

🙂 Eric

#918989

Shane
Supporter

Languages: English (English )

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

Hi Eric,

Thank you for contacting our support forum.

I'm assuming that this is in a parent-child relationship. If so then you should be able to use the same id that you using for the [wpv-post-title] shortcode and pass it in the wpv-post-field shortcode.

Thanks,
Shane

#919104

Thank you, Shane. Using your guidance, I stumbled around and figured it out. Here are the shortcodes I used ...

Agent: [wpv-post-title id="$listing-agent"]
Phone: [wpv-post-field name="wpcf-agent-phone" id="$listing-agent"]
Email: [wpv-post-field name="wpcf-agent-email" id="$listing-agent"]

The first shortcode displays the name of the agent (custom post type).
The second shortcode pulls and displays the phone field data from the agent custom post type.
The third shortcode pulls and displays the email field data from the agent custom post type.