Skip Navigation

[Resolved] Toolset View – Get page post id inside another post type loop

This support ticket is created 3 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 1 reply, has 2 voices.

Last updated by Shane 3 years, 6 months ago.

Assisted by: Shane.

Author
Posts
#2058707

Hello, I have two custom post types: Artist and Song with "many to many" relationship. I created a view for each Artist to display related Song posts. Inside the View loop I called a function by using shortcode and I need the function to get the current post id (Artist Id) and not the view loop post id (Song Id). I tried to global $post instead of get_the_ID(), but it still gets me the post ID of the loop.

#2058771

Shane
Supporter

Languages: English (English )

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

Hi Xiaolin,

Thank you for getting in touch. If you're doing this in a view then you can use the shortcode below to get the id of the page.

[wpv-post-id item='$current_page'] 

Here is a little more information on the item attribute and the parameters that it accepts.
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/

Thanks,
Shane