Skip Navigation

[Closed] Conditionally display parent's title

This support ticket is created 8 years 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.

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 3 replies, has 2 voices.

Last updated by Minesh 8 years ago.

Assisted by: Minesh.

Author
Posts
#376567

I have a View where I display courses.
I have a Discount custom post type which is parent of Course.
Depending on which Discount post is parent of the current post, I want to display either the course's price field value, or the Discount's title (which is the discounted price).
How can I make this condition? How can I refer to this:

If parent Discount's title = "$24" then display parent Discount's title.

#376593

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

To include a field from the parent post, you would use the following shortcode:

[types field="xxxx" id="$yyyy"][/types]

Where:
"xxxx" is the field of the parent you want to show, and "yyyy" is the slug-name of the parent post. The “$” is required, as this represents a variable where the parent post name will be replaced by the post ID, internally.

Now, to display conditionally, for example:

[wpv-conditional if="( '[types field="your-field" id="$parent-post-slug"][/types]' eq '$24' )"]
 
display something here
 
[/wpv-conditional]

Where:
Replace "your-field" with your original field name
Replace "parent-post-slug" with your parent post slug.

I hope this solution will help you to resolve your issue.

#376783

This doesn't work.
Why not?
The parent object is called "discount" and I want to refer to its post title.

[wpv-conditional if="( [types field='post-title' id='$discount'][/types] eq '$24' )"]
   <div class="row courseprice">$24</div>
[/wpv-conditional]
[wpv-conditional if="( [types field='post-title' id='$discount'][/types] ne '$24' )"]
   <div class="row courseprice">$[types field="price"][/types]</div>
[/wpv-conditional]

It doesn't work this way either:

[wpv-conditional if="( [wpv-post-title id='$discount'] eq '$24' )"]

I noticed that you placed extra ' ' around the types shortcode, but the GUI-generated conditional output code doesn't have those. Anyhow, even by adding those extra characters to the code, it still doesn't work.

#377095

Minesh
Supporter

Languages: English (English )

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

Could you please send me problem URL as well as which view you are using?

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

I have set the next reply to private which means only you and I have access to it.

The topic ‘[Closed] Conditionally display parent's title’ is closed to new replies.