Skip Navigation

[Resolved] Display Post ID of related post

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 1 reply, has 2 voices.

Last updated by Waqar 6 months, 2 weeks ago.

Assigned support staff: Waqar.

Author
Posts
#2416449

In a View for a custom post type, my view loop displays fields from the related posts using those related fields from the Fields and Views interface. I want to add a CSS id containing the Post ID of the related post being displayed, but there is no button for Post ID within the post type I'm displaying. How do I display the current, related Post ID in a View loop?

#2416555

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

post-ID-relationship-selection.png
post-ID-fields-and-text.png

Hi,

Thank you for contacting us and I'd be happy to assist.

In the Fields and Views interface, you'll see the option to insert the "Post ID", in the standard WordPress fields.
( example screenshot: post-ID-fields-and-text.png )

From the next screen, you can also select the source of the relationship post type, to use for that ID.
( example screenshot: post-ID-relationship-selection.png )

That interface will add the "wpv-post-id" shortcode (ref: https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-post-id) for the post ID with the item attribute ( ref: https://toolset.com/documentation/user-guides/views-shortcodes/item-attribute/ ) and you can also add the shortcode directly, for example:


[wpv-post-id item="@post-book.parent"]

In this example, the "post-book" is the relationship's slug and the "parent" part tells that the target post type is the parent in the relationship.

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar