Skip Navigation

[Résolu] Check if parent post exists

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem:
Check if parent post exists with Types 3.0

Solution:
You can use [wpv-conditional] shortcode to check if parent exists or not.

For example:

[wpv-conditional if="( '[wpv-post-id item="@relationship-slug.parent"]' ne '' )"]
 
parent exists
 
[/wpv-conditional]

You can find proposed solution, in this case, with the following reply:
https://toolset.com/forums/topic/check-if-parent-post-exists/#post-911756

Relevant Documentation:
=> https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

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.

Our next available supporter will start replying to tickets in about 0.05 hours from now. Thank you for your understanding.

This topic contains 7 réponses, has 2 voix.

Last updated by PiotrO586 Il y a 3 années et 1 mois.

Assigned support staff: Minesh.

Auteur
Publications
#911603

Hi,

with the new version of Toolset, how to check if a child post has a parent one?
This approach apparently doesn't work anymore?: https://toolset.com/forums/topic/conditional-output-with-post-relations/

#911657

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - I would like to know that are you using new post relationships that is made available with latest Types plugin version 3.0 or have you migrated your legacy (old) relationship created using Types plugin before version 3.0?

What is your parent post type and child post types? Could you please send me screenshot of page:
=> Toolset => Relationships

#911747
screen.png

Hi Minesh,

my site wasn't ready when the Types 3.0 was released and I decided to set my website up from scratch, using only the newest releases of the Toolset software, so I didn't migrate anything.

I attach the screen.

#911756

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - With Types 3.0, you should try to use following code to check if parent exists or not.

To check if parent exists:

[wpv-conditional if="( '[wpv-post-id item="@relationship-slug.parent"]' ne '' )"]

parent exists

[/wpv-conditional]

To check if NO parent exists:

[wpv-conditional if="( '[wpv-post-id item="@relationship-slug.parent"]' eq '' )"]

no parent exists

[/wpv-conditional]

Where:
- Replace relationship-slug with your original post relationship slug.

#911807

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

Could you please confirm - is the solution I shared works for you?

#912082

Thanks Minesh, it works.

One more thing, how to show only these posts in archive which have parent by using Query Filter?

#912162

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

Glad to know that the solution I shared works for you.

May I kindly ask you to open a new ticket with your each new question. This will help other users searching on the forum as well help us to write correct ticket resolution summery.

You may create a new ticket and feel free to assign it to me.

#912232

I will. Thank you.