• So I have this Optin Form plugin that gives me a [optinform] shortcode. How can I make the optin form appear as a response to a widget button being clicked on screen?

    Basically I want to work like this:
    Click “sign up” button (button created by widget plugin) >>> Optin Form popup appears

Viewing 1 replies (of 1 total)
  • Hi

    In your child theme’s header.php

    <script>
    function execute_mcode() {
       var url="<?php echo get_template_directory_uri(); ?>/yourshortcode.php";
       jQuery.post(url,function(data){
       console.log(data);
       });
    }
    </script>

    In your yourshortcode.php:
    <?php echo do_shortcode('[optinform]'); ?>

    and use the following in your button:

    onclick="execute_mcode()"

    All the best!

Viewing 1 replies (of 1 total)
  • The topic ‘Execute shortcode in response to a button’ is closed to new replies.