I’m trying to embed a Gravity Form on all of my blog posts. I initially tried to do this with ‘Ad Inserter’ plugin and works ok. But then when I turned on Ajax (ajax=“true”) in shortcode there were conflicts.
So I created a custom plugin to embed the form in every post…this works on desktop and when I test in mobile on chrome—but on safari its just a spinning wheel of death:
// Function to append Gravity Form to post content
function append_gravity_form_to_posts($content) {
if (is_single() && in_the_loop() && is_main_query()) {
ob_start();
gravity_form(1, false, false, false, '', true);
$form = ob_get_clean();
$content .= $form;
}
return $content;
}
add_filter('the_content', 'append_gravity_form_to_posts');
I did test just embedding the form via blocks on one page and it works fine on desktop and mobile. but again, I need to include the form on over 100 posts.
anything I’m doing wrong here or is there a better way to embed to ensure that Ajax is working correctly?