Skip Navigation

[Resolved] How to display the post title of another post whose ID is stored as a custom field

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

Problem:
Posts are connected to other posts by storing the ID of the connected post as a custom field.

How to display the post title of the connected post?

Solution:
Use the id attribute to switch the context for the wpv-post-title shortcode, for example:

[wpv-post-title id="[types field='my-custom-field' output='raw'][/types]"]

Relevant Documentation:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-title

This support ticket is created 6 years, 10 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by gavinS-2 6 years, 10 months ago.

Assisted by: Nigel.

Author
Posts
#611017

I have a type (accessory-items) which saves the post ID of another type (item-models) as one of it's fields.

I am saving the post ID as a field because the post already has a parent field which is a different item-model post. (There is a many to many relationship between item-model and item-model.)

However in my view I wish to display the post title for the saved post id, not the ID number. How do I do this?

Sorry this seems simple, but I can't seem to find any related tickets..

#611049

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

You can use the output of your types field to generate the id attribute of the wpv-post-title shortcode (the id attribute will tell the shortcode to get the title from a particular post, not the current one).

[wpv-post-title id="[types field='my-custom-field' output='raw'][/types]"]

You'll need to edit the field slug, of course.

#611068

Perfect

Thanks Nigel