Skip Navigation

[Resolved] Content should be empty if no parent relationship

This support ticket is created 6 years, 6 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

Author
Posts
#577164
Screen Shot 2017-10-09 at 11.31.21 AM.png

Dear Sir/Madam,

I have a post type "coupon", it is possible to have two related parents, "merchant" and "advertiser", I want to get the parent title name if existed by adding code in View

Issued By: [wpv-post-title id="$merchant"], [wpv-post-title id="$advertiser"]

Refer to the screenshot, only the coupon springb-01 has parent relationship to merchant and advertiser, all other shows its title name if no advertiser parent relationship, I suppose it should not be shown.

Best regards,

Kelvin.

#577185

Dear Kelvin,

It is expected result, if there isn't parent "advertiser" post set, then the shortcode [wpv-post-title id="$advertiser"] will display the current child "coupon" post information.

In your case, you can use [wpv-conditional] shortcode to check if there is any parent "advertiser" post setting, then display the parent advertiser" post title, for example:

[wpv-conditional if="( NOT(empty($(__wpcf_belongs_advertiser_id))) )"]
    [wpv-post-title id="$advertiser"]
[/wpv-conditional]

More help:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-fields-and-other-elements-for-emptynon-empty-values/

#577225

Dear Luo Yang,

I paste below code

        	[wpv-conditional if="( NOT(empty($merchant)))"]
				[wpv-post-title id="$merchant"]
			[/wpv-conditional]
        	[wpv-conditional if="( NOT(empty($advertiser)))"]
				[wpv-post-title id="$advertiser"]
			[/wpv-conditional]

but still, show the child post title if no parent advertiser

#577229

Please try below codes:

[wpv-conditional if="( NOT(empty($_wpcf_belongs_merchant_id)))"]
    [wpv-post-title id="$merchant"]
[/wpv-conditional]
[wpv-conditional if="( NOT(empty($_wpcf_belongs_advertiser_id)))"]
    [wpv-post-title id="$advertiser"]
[/wpv-conditional]

The "_wpcf_belongs_merchant_id" and "_wpcf_belongs_advertiser_id" are hidden custom fields for storing the parent post IDs.

#577243
Screen Shot 2017-10-09 at 5.46.51 PM.png
Screen Shot 2017-10-09 at 5.47.17 PM.png

Dear Luo Yang,

I tried to copy and paste your code but the same result.

Best regards,

Kelvin.

#577529

Thanks for the details, you are right, please modify the codes as below, and test again:

[wpv-conditional if="([wpv-post-id id='$merchant'] ne [wpv-post-id])"]
[wpv-post-title id="$merchant"]
[/wpv-conditional]
[wpv-conditional if="([wpv-post-id id='$advertiser'] ne [wpv-post-id])"]
[wpv-post-title id="$advertiser"]
[/wpv-conditional]

Above codes will be able to check if the parent post IDs, if they not equal to current child post ID, then display the parent post information.

#578698

Dear Luo Yang,

I find my code result is same as yours.

Yours

[wpv-conditional if="( NOT(empty($_wpcf_belongs_merchant_id)))"]
    [wpv-post-title id="$merchant"]
[/wpv-conditional]
[wpv-conditional if="( NOT(empty($_wpcf_belongs_advertiser_id)))"]
    [wpv-post-title id="$advertiser"]
[/wpv-conditional]

Mine

[wpv-conditional if="( NOT(empty($merchant)))"]
	[wpv-post-title id="$merchant"]
[/wpv-conditional]
  	[wpv-conditional if="( NOT(empty($advertiser)))"]
	[wpv-post-title id="$advertiser"]
[/wpv-conditional]
#578882

I have tested above codes in my localhost, it works fine:
https://toolset.com/forums/topic/content-should-be-empty-if-no-parent-relationship/#post-577529

If you still need assistance for it, please provide a test site with same problem, I can setup a demo for you.

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