Multi-step slider doesn’t work with shortcode
-
Hi,
I’m adding the contact form shortcode with a function on my functions.php file. The problem is that the form slider doesn’t work if I do that way, it only work if I add the shortcode into a page or widget.Is it possible to do it this way?
Thanks
-
I’m adding the contact form shortcode with a function on my functions.php file.
can you share the function and filter you are using?
Yes of course
// Trigger a Modal Popup on the Click of a Menu Element // https://ultimate.brainstormforce.com/docs/trigger-a-modal-popup-on-the-click-of-a-menu/ function ultimate_VC_modal_popup() { if (ICL_LANGUAGE_CODE == "pt-pt") { echo do_shortcode( ' [ultimate_modal modal_on="custom-selector" modal_title="Localizar representante" modal_on_selector=".display-contact-popup" modal_size="small" modal_style="overlay-fade" el_class="dealer-popup" overlay_bg_opacity="80" img_size="20" close_icon_position="popup-top-right"] <p class="intro">De forma a podermos encontrar um representante na sua zona, preencha os campos a baixo e entraremos em contacto consigo.</p> [cf7form cf7key="revendedor-pt"] [/ultimate_modal]' ); } } add_action('wp_footer', 'ultimate_VC_modal_popup');the issue may be with the embedding of the cf7 shortcode within the other shortcode…
Have you tried simply:
echo do_shortcode('[cf7form cf7key="revendedor-pt"]');?Hi,
I didn’t try it but I need to have that way, because the contact form needs to be showed inside a modal box and the other shortcode is to do thatI didn’t try it but I need to have that way,
please try first, and let me know what you get
the other possibility which it does not work is because you might be hooking it too late on ‘wp_footer’. Does it work if you inslude the wrapping shortcode inside the page content?
It works if I use the shortcode isolated, like this:
function ultimate_VC_modal_popup() { echo do_shortcode( '[cf7form cf7key="teste"]' ); } add_action('wp_footer', 'ultimate_VC_modal_popup');But as I said I need to have the contact form inside the other shrotcode… if there’s no possibility to work like that, I will forget the idea to have the slider in the form
It works if I use the shortcode isolated, like this:
good, so we have identified the reason.
if there’s no possibility to work like that
not with this approach at least for now. I may in the future look at why this does not work, but for now you need a different approach.
use the
'do_shortcode_tag'filter introduced in v4.7 of WP,add_filter('do_shortcode_tag', 'wrap_cf7sg_form',10,3); function wrap_cf7sg_form($output, $tag, $attr){ //check if this is a form shortcode. if('cf7form' !== $tag) return $output; //check if this is the right form. if('revendedor-pt' != $attr['cf7key'] return $output; $output = do_shortcode(' [ultimate_modal modal_on="custom-selector" modal_title="Localizar representante" modal_on_selector=".display-contact-popup" modal_size="small" modal_style="overlay-fade" el_class="dealer-popup" overlay_bg_opacity="80" img_size="20" close_icon_position="popup-top-right"] <p class="intro">De forma a podermos encontrar um representante na sua zona, preencha os campos a baixo e entraremos em contacto consigo.</p> '.$output.'[/ultimate_modal]'); return $output; }Hi, thanks for your answer.
When I added that code on functions file the website doesn’t work. My WordPress versions is 5.5.3the website doesn’t work.
did you switch on WP_DEBUG mode to see where the error is coming from?
… there is a missing bracket in the code, try
add_filter('do_shortcode_tag', 'wrap_cf7sg_form',10,3); function wrap_cf7sg_form($output, $tag, $attr){ //check if this is a form shortcode. if('cf7form' !== $tag) return $output; //check if this is the right form. if('revendedor-pt' != $attr['cf7key']) return $output; $output = do_shortcode(' [ultimate_modal modal_on="custom-selector" modal_title="Localizar representante" modal_on_selector=".display-contact-popup" modal_size="small" modal_style="overlay-fade" el_class="dealer-popup" overlay_bg_opacity="80" img_size="20" close_icon_position="popup-top-right"] <p class="intro">De forma a podermos encontrar um representante na sua zona, preencha os campos a baixo e entraremos em contacto consigo.</p> '.$output.'[/ultimate_modal]'); return $output; }Hi, it still doesn’t work, I think it’s because that code doesn’t add the shortcode into the HTML, right? I need to add it somewhere, ie, in the footer
you said,
t works if I use the shortcode isolated, like this:
function ultimate_VC_modal_popup() { echo do_shortcode( '[cf7form cf7key="revendedor-pt"]' ); } add_action('wp_footer', 'ultimate_VC_modal_popup');have you tried?
I, yes I tried and it works as I said. But how can I use the code you gave:
add_filter('do_shortcode_tag', 'wrap_cf7sg_form',10,3); function wrap_cf7sg_form($output, $tag, $attr){ //check if this is a form shortcode. if('cf7form' !== $tag) return $output; //check if this is the right form. if('revendedor-pt' != $attr['cf7key']) return $output; $output = do_shortcode(' [ultimate_modal modal_on="custom-selector" modal_title="Localizar representante" modal_on_selector=".display-contact-popup" modal_size="small" modal_style="overlay-fade" el_class="dealer-popup" overlay_bg_opacity="80" img_size="20" close_icon_position="popup-top-right"] <p class="intro">De forma a podermos encontrar um representante na sua zona, preencha os campos a baixo e entraremos em contacto consigo.</p> '.$output.'[/ultimate_modal]'); return $output; }With this one:
function ultimate_VC_modal_popup() { echo do_shortcode( '[cf7form cf7key="revendedor-pt"]' ); } add_action('wp_footer', 'ultimate_VC_modal_popup');you need to as both of the above codes to your functions.php file
The topic ‘Multi-step slider doesn’t work with shortcode’ is closed to new replies.