Skip Navigation

[Resolved] wpv-conditional not working with [types item='']

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.

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

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 12 replies, has 3 voices.

Last updated by vimalS 5 years, 10 months ago.

Assisted by: Shane.

Author
Posts
#1207631

I am trying to:

[wpv-conditional if=" '[types field='usp-1-has-overlay' output='raw' item='[types field='usp-set-post-id' output='raw'][/types]'][/types]' eq '0' "]
test data [/wpv-conditional]

Link to a page where the issue can be seen:

I expected to see: test data

Instead, I got: blank

Condition is working with [wpv-conditional if=" '[types field='usp-1-has-overlay' output='raw' item='75'][/types]' eq '0' "]
test data [/wpv-conditional]

static id in item parameter.

#1207734

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Vimal,

Thank you for contacting our support forum.

Could you try adding debug='true' to the conditional shortcode that doesn't work and let me know what the output on the frontend is.

This will help me to debug the conditional to see where it is failing.

Thanks,
Shane

#1208075

I did like this

 [wpv-conditional debug='true' if=" '[types field='usp-1-has-overlay' output='raw' item='[types field='usp-set-post-id' output='raw'][/types]'][/types]' eq '0' "]
test data [/wpv-conditional]

But it is not displaying anything

#1208606

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Vimal,

Thank you for trying.

Would you mind allowing me to have a look ?

The private fields have been enabled for your next response. Also please send me the link of the page that this code is being used on.

Thanks,
Shane

#1210088

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Vimal,

So I understand the issue here and I believe its because of the nested quotations.

We can write a simple custom shortcode to resolve this.

I went ahead a wrote the custom shortcode for you and set it up

function usp_tag( $atts ) {

	// Attributes
	$atts = shortcode_atts(
		array(
			'field' => '',
			'current_id' => '',
		),
		$atts
	);

	$usp_overlay_id = get_post_meta(get_the_ID(),'wpcf-usp-set-post-id');
  	$has_usps_overlay = get_post_meta($usp_overlay_id[0],'wpcf-usp-1-has-overlay');
	return $has_usps_overlay[0];

}
add_shortcode( 'usp_tag', 'usp_tag' );

Your function should be working fine now.
Thanks,
Shane

#1210375

Hi Shane,

I have three fields wpcf-usp-1-has-overlay,wpcf-usp-2-has-overlay,wpcf-usp-3-has-overlay, How can I update above shortcode to make it work for all 3 fields?

Thanks

#1210621

Hi, Shane is out today and will return tomorrow to continue assisting you with this ticket.

#1211362

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Vimal,

The 3rd custom field, where is this located?

Is it located in the same place as the wpcf-usp-2-has-overlay field ?

Also what should we do with this field.

Please let me know.
Thanks,
Shane

#1211705

Is it located in the same place as the wpcf-usp-2-has-overlay field ?
Ans : yes

Also what should we do with this field?
Ans : it is checkbox field, need to check if it has value 1 or 0

#1211905

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Vimal,

So you want to check between both of them and only return the one that is selected correct?

The code should only give you 1 for the overlay thats selected. Please confirm so I can make the modification.

Thanks,
Shane

#1212403

Hi Shane,

So you want to check between both of them and only return the one that is selected correct?
Ans : No I want to get 3 values, separate value for each.

Thanks

#1212639

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Vimal,

I will just modify the shortcode to take the slug of the field.

function usp_tag( $atts ) {
 
    // Attributes
    $atts = shortcode_atts(
        array(
            'field' => '',
            'current_id' => '',
        ),
        $atts
    );
 
    $usp_overlay_id = get_post_meta(get_the_ID(),'wpcf-usp-set-post-id');
    $has_usps_overlay = get_post_meta($usp_overlay_id[0],$atts['field']);
    return $has_usps_overlay[0];
 
}
add_shortcode( 'usp_tag', 'usp_tag' );

So now to use the shortcode you will do it like this [usp_tag field='wpcf-usp-2-has-overlay']

You will need to update the code in Toolset -> Settings -> Custom Code.

Thanks,
Shane

#1212998

My issue is resolved now. Thank you!