Skip Navigation

[Resuelto] Check if a page is a subpage (same CPT) and then show content

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

Problem: I have a hierarchical post type. I would like to use conditional HTML to determine if the post is a top level post, or if the post has a parent.

Solution: Use the post ID in the conditional:

[wpv-conditional if="([wpv-post-id item='$parent'] ne [wpv-post-id])"] this is a subpage [/wpv-conditional]
This support ticket is created hace 5 años, 5 meses. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Etiquetado: ,

Este tema contiene 2 respuestas, tiene 2 mensajes.

Última actualización por Zayne hace 5 años, 5 meses.

Asistido por: Christian Cox.

Autor
Mensajes
#1275123

I need to group lists of Works (CPT) together, for instance when there are 5 individual works in a Suite of works. When I view one of the individual works, I want to be able to show a link to the parent work. I know I can do this with [wpv-post-link item="$parent"], but the issue is that I want to add the title "Parent Work:" whenever there is one. When there isn't a parent work, I don't want the title to show. Thus I need to use a conditional. However, I can't get any conditional to work.

I've tried

[wpv-conditional if="[wpv-post-link item="$parent"] ne ''" ]

and many other combinations of this, but nothing works. What can I do?

#1275153

Hi, you can use the post ID shortcode to test whether there is a hierarchical parent post ID that is different from the current post ID. The system will return the current post's ID if no hierarchical parent post exists.

[wpv-conditional if="([wpv-post-id item='$parent'] ne [wpv-post-id])"] this is a subpage [/wpv-conditional]
#1275195

Aha! Thanks for the help.