Shortcode For WordPress

User 2858481 Photo


Registered User
25 posts

Hey guys,

Does anyone know if it's possible to use shortcode in a WordPress site to add the form to a page? The problem I am running into is that when using a page builder like Elementor or Divi, adding the form code in an html widget causes everything on the page to disappear while editing. One of the devs at Elementor told me that it's because of the document.write part of the web form code.

On the live site, everything works and the form is there, but it's during the page editing that things are not visible inside of WordPress.

Thanks
User 122279 Photo


Senior Advisor
14,447 posts
Online Now

Hi, Someone might perhaps be able to help. Otherwise your best bet would be asking in the user forums or the support of the page builders you are using.
Ha en riktig god dag!
Inger, Norway

My work in progress:
Components for Site Designer and the HTML Editor: https://mock-up.coffeecup.com


User 2147646 Photo


Registered User
233 posts

In your themes functions.php file you can add something like this
function ccform_func() {
return 'Place form script here';
}
add_shortcode('ccform', 'ccform_func');


And then you can use the shortcode [ccform]

User 2858481 Photo


Registered User
25 posts

Thanks. I have contacted Elementor and was told that the problem is with the document.write in the Web Form Builder code. That statement causes everything to disappear in the page builder.

Thanks Jamo, I haven't tried your suggestion, but perhaps I could give it a go.

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.