Skip Navigation

[Resuelto] How to display the link to the parent page only on children pages?

This support ticket is created hace 4 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.

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.

This topic contains 2 respuestas, has 2 mensajes.

Last updated by kasparB hace 4 años, 5 meses.

Autor
Mensajes
#1374539

I want to use one layout for child and parent pages. On the child pages I want to display a link to the parent. The wordpress hierarchy is used.
But I can’t build the if-else construct correctly to display only on child pages.
Please help me figure it out.

At the moment I tried to use such a code:
[wpv-conditional if="( '[wpv-attribute]' ne 'parent' )"]a part of [wpv-post-link id="$parent"][/wpv-conditional]

The result can be seen, for example, on this page:

hidden link

This is the parent page and a link to itself is displayed.
On child pages, the code works correctly.

P.S. Sorry for my bad English.

#1374593

wpv-attribute is not a Toolset ShortCode, by my Knowledge.
Also there is no shortcode that tells you "parent" or "child" related to the page you are seeing, depending on the WordPress Pages hierarchy.

$parent is a value that works indeed with WordPress Hierarchies, as you can read here https://toolset.com/documentation/user-guides/views-shortcodes/item-attribute/, however, the evaluation you created cannot work, as the ShortCode does not exist you use, and by my knowledge there is no method to determine this in the Front End (wether page is parent or not).

What you can do, is actually check on any field of "the parent", so for example, you could check if the (current page) has a $parent ID.
If not, that means you are not on a Child page, if yes, it means you are on a Child page.

So for example, below could do the trick:

[wpv-conditional if="( '[wpv-post-id item="$parent"]' ne '' )"]
  THIS IS A CHILDS PAGE and has PARENT PAGE with ID [wpv-post-id item="$parent"], because the Parent ID is NOT empty.
[/wpv-conditional]
[wpv-conditional if="( '[wpv-post-id item="$parent"]' eq '' )"]
  THIS IS NOT A CHILDS PAGE because NO PARENT PAGE with ID [wpv-post-id item="$parent"] exists
[/wpv-conditional]

This, inserted in the Layout, should allow you to at least determine if a parent exists, hence, almost perfectly achieve the goal.
I say almost because in fact this is not a check for wether a parent exists or not, it's just a check for if the current post has a parent page ID.

But it should do the same trick.
Can you confirm?

#1374659

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.