Skip Navigation

[Resolved] Check if parent post exists

This thread is resolved. Here is a description of the problem and solution.

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 support ticket is created 5 years, 10 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.

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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 7 replies, has 2 voices.

Last updated by PiotrO586 5 years, 10 months ago.

Assisted by: Minesh.

Author
Posts
#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: English (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: English (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: English (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: English (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.

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