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:
This is the parent page and a link to itself is displayed.
On child pages, the code works correctly.
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 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
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.