Saltar navegación

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

This support ticket is created 4 years, 3 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 -

Zona horaria del colaborador: America/Jamaica (GMT-05:00)

Este tema contiene 1 respuesta, tiene 2 mensajes.

Última actualización por Shane 4 years, 3 months ago.

Asistido por: Shane.

Autor
Mensajes
#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
Colaborador

Idiomas: Inglés (English )

Zona horaria: 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