Site logo

Archived topic

Convertflow - how to add script

11 replies · Started by Kevin on December 31, 2018

Viewing posts 1–12 of 12

Here is the script:

<script>
if (window.convertflow == undefined) {
var script = document.createElement('script');
script.async = true;
script.src = "https://js.convertflow.co/production/websites/3983.js";
document.body.appendChild(script);
};
</script>

I added the code in elements to GP_Head and told it to show on a specific page (see admin area)

I am trying to get this form to display with a background of #F2F2F2 and have it float centered left/right up/down

Hi there,

Are you sure that code is supposed to go in wp_head?

I'm not seeing a form showing up on the page you linked.

As for changing the background color, I don't believe CSS will work inside <script> tag like that. Have you checked with the code author on how to do that?

On my other wordpress site (not generatepress) I just this script into a code box and it works perfect.

I have no idea on how to do this on generatepress so I tried following the tutorial on elements but I got nowhere.

How do I inject this code onto a single WordPress page in generatepress

Thanks!

How exactly did you add it to your previous theme? Inside the content area? Typically, WordPress doesn't allow script elements inside the content.

They have a "code" box you drop into a section and just dump the script inside.

You can see it in operation Wildernessedge.thedev.ca right at bottom just before the footer.

How do I add this code to generatepress? My goal is transfer my current enfold theme to yours?

If you're using the new editor in WordPress, you should be able to add a Code block, and put that code into the block.

That should make the form appear wherever you add the code.

Thanks, but I have gutenberg disabled.
What is the next best method?

Thanks much,
Kevin

You could create a shortcode with it:

add_shortcode( 'convertflow', function() {
    ob_start();
    ?>

        Your script here

    <?php
    return ob_get_clean();
} );

Then you can add the [convertflow] in your content.

ok, so I installed the snippet plugin

Put an echo line to make sure it was working on my page, which is does

But still no love in executing this js

add_shortcode( 'convertflow', function() {
ob_start();
?>
// Start your PHP below

echo 'short code example';

// End your PHP above
<script>
if (window.convertflow == undefined) {
var script = document.createElement(‘script’);
script.async = true;
script.src = “https://js.convertflow.co/production/websites/3983.js”;
document.body.appendChild(script);
};
</script>

<?php
return ob_get_clean();
} );

Thanks for your patience

Hmm, are there any errors in the console if you right click + inspect?

If the code is being outputted within the HTML, then there isn't much more the theme itself can do. It's on the script itself to take over and display what it needs to display.

ok. super strange. If I switch the whole thing over to the Enfold theme it works. Just get this error when working with generatepress theme.

thanks for all your help.

Kevin

That is strange. Can you link me to a specific page where it should be showing up inside the content?

This archived topic is closed to new replies.