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.
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
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
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
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
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
Hi, Shane is out today and will return tomorrow to continue assisting you with this ticket.
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
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
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
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
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
My issue is resolved now. Thank you!