Skip Navigation

[Resolved] If condition for Intermediary parent

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

Last updated by kellyR 1 year, 9 months ago.

Assisted by: Minesh.

Author
Posts
#2543857

Tell us what you are trying to do?
Place a shortcode within a shortcode.

Is there any documentation that you are following?
Using the Editor menu for If conditions.

Is there a similar example that we can see?
Yes

What is the link to your site?
Just need advise thanks.

I could not find specifics on this issue.

I have Map and Article post types.
They are related, Map is parent and Article is child.
I have an Intermediary post type "map-article".
It has a radio button field, selectors are (parent, child, both).
I use a View (selecting the intermediary posts map-article).
I want to display featured image of Map or Article based on radio item selected.

All that said I have a shortcode that WORKS here:
[wpv-conditional if="( '[wpv-post-featured-image output="url" item="@map-article.child"]' ne '' )"]

I would like to use this code but does not work, front end image area is blank:
[wpv-conditional if="( '[wpv-post-featured-image output="url" item="@[wpv-post-type].child"]' ne '' )"]

My guess is the shortcode nesting is too deep?
Please, would you have advice for a shortcode here?
I am not familiar with PHP.

Thank you so much in advance!
Kelly

#2543999

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Can you please share screenshot of your radio field value configurations and based on that I will share the updated condition.

#2544239
If-condition-for-Intermediary-parent-230130.jpg

Item 1 is the Relationship Intermediary field - radio selector, slug "show-related".

Item 2 is the Map > Article Relationship Form.

Item 3 is from the Content Template.

Item 4 is the front end result when working (using the "WORKS" shortcode above.

When using the second shortcode above the thumbnail image would not be showing, not even an image error icon.

#2544687

Minesh
Supporter

Languages: English (English )

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

Can you please clarify based on the custom field values (parent,child,both,none) "show-related" what content you want to display?

Basically - the condition would be as follows:

[wpv-conditional if="( '[types field='show-related' output='raw'][/types]' eq 'parent' )"]
// add whatever thing you want to display when "show-related" field value equal to 'parent'
[/wpv-conditional]

[wpv-conditional if="( '[types field='show-related' output='raw'][/types]' eq 'child' )"]
// add whatever thing you want to display when "show-related" field value equal to 'child'
[/wpv-conditional]

[wpv-conditional if="( '[types field='show-related' output='raw'][/types]' eq 'both' )"]
// add whatever thing you want to display when "show-related" field value equal to 'both'
[/wpv-conditional]

More info:
- https://toolset.com/documentation/legacy-features/views-plugin/using-shortcodes-in-conditions/

#2545031
If-condition-for-Intermediary-parent-230131.jpg

I am sorry I think my description my have been too complicated.
The shortcode in this attached image does not work.
I think the problem may be that the nesting is too deep.
I would like to know if there is another way to make this work.

#2545333

Minesh
Supporter

Languages: English (English )

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

But the shortcode you shared - you are using wrong way.

You added [wpv-post-type] shortcode but instead that you will have to use the post relationship slug.

If you do not know how to use conditoinal statements then please share problem URL where you added those shortcode as well as share admin access details with information about what is your expected result and what you want to display conditoinally.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) 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 have set the next reply to private which means only you and I have access to it.

#2545681

This shortcode is within a content template, within a view, that filters for the intermediary post types including map-article.
I guess I didn't explain that well enough in the very beginning above.
If [wpv-post-type] alone in entered into this template it shows on the front end as "map-article", this is not the problem.
[wpv-post-type] does not resolve when used in the code below, but it works otherwise...
[wpv-conditional if="( '[wpv-post-featured-image output="url" item="@[wpv-post-type].child"]' ne '' )"]

#2545689

P.S.
I think this is the answer to my question. The problem is caused by nesting the shortcode [wpv-post-type] too deep.
I will do it the long way using multiple templates.

Thank you Minesh!
I hope this helps someone else too.

#2545733

Minesh
Supporter

Languages: English (English )

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

Glad to know that and yes that way shortcode will not be parsed. You're welcome to close the ticket.

#2545753

My issue is resolved now. Thank you!