• Resolved isabelk2j

    (@isabelk2j)


    Good Day,
    I added a contact form to a page using contact form 7 shortcode inside a shortcode and it … everything works fine except that the contact form 7 doesn’t submit over Ajax but reloads the page with something like this as the URL (https://localhost/WEBSITE/request-quote/?product-name=random%20name#wpcf7-f3123-p3143-o2)

    function get_for_which_product_text($atts, $content) {
    	$atts = shortcode_atts( array(
    		'content' => '[contact-form-7 id="3123"]',
    	), $atts, 'load-for-which-product-request-quote' );
    
    	ob_start();
    	if (isset($_GET['product-name'])) {
    		$getProductTitle = $_GET['product-name'];
    	  	$product_link = get_page_by_title($getProductTitle,  OBJECT, 'product');
    	  	$context = __('for %1s%2s%3s', GET_TEXT_DOMAIN);
    	  	?>
    		<div class="request_custom-quote">
    			<p><?php echo sprintf(__('Fill The form below to request quote %s', GET_TEXT_DOMAIN),$context); ?></p>
    			<p><?php echo __('If you have any questions or would like more information regarding services or estimates, please use our %1$s%2$scontact page%3$s%4$s instead or call: %2$sPHONE NUMBER%3$s.', GET_TEXT_DOMAIN); ?></p>
    			<div class="the_rcq_form"><?= do_shortcode($atts['content']); ?></div>
    		</div>
    	  	<?php
    
    	}
    
    	return ob_get_clean();	
    }
    add_shortcode('load-for-which-product-request-quote', 'get_for_which_product_text');
    

    What am i doing wrong?

    • This topic was modified 5 years, 5 months ago by isabelk2j.
    • This topic was modified 5 years, 5 months ago by Jan Dembowski.
Viewing 1 replies (of 1 total)
  • Thread Starter isabelk2j

    (@isabelk2j)

    Issue Resolved by using this below code instead of what i used earlier, after reading the Shortcode API codex page

    <div class="the_rcq_form"><?= do_shortcode($content); ?></div>

    Thanks

Viewing 1 replies (of 1 total)
  • The topic ‘Not doing Ajax if Shortcode is used’ is closed to new replies.