• Simon

    (@simonfricker)


    I am creating a custom theme.
    I need to use the shortcode for the email petition outside of the_content();

    <?php echo do_shortcode('[emailpetition id="1"]'); ?>

    When I do this, the petition appears normal. However when the user submits the form, the page is refreshed and the user is not added to the list.

    When I use the shortcode in the content editor, everything works fine.

    • This topic was modified 4 years, 7 months ago by Simon.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author SpeakOut!

    (@123host)

    What you are trying is a bit beyond the scope of the support I can offer.

    But first thing I would check is the developer console for errors.

    Are you loading jQuery?

    Thread Starter Simon

    (@simonfricker)

    After some more investigation. The JS is not loaded when echo do_shortcode is used. Manually adding these bits of JS allow the form to work but this feels like a bad solution.

    <script> var dk_speakout_js = {"ajaxurl":"<?php echo get_home_url(); ?>/wp-admin/admin-ajax.php"}; </script>
    
    <script type='text/javascript' src='<?php echo get_home_url(); ?>/wp-content/plugins/speakout/js/public.js' defer onload=''></script>
    • This reply was modified 4 years, 7 months ago by Simon.
    • This reply was modified 4 years, 7 months ago by Simon.
    Plugin Author SpeakOut!

    (@123host)

    Thanks for the update.

    I thought the plugin tested for query and loaded it if not found. Not something I have looked at in a long time.

    With plenty of time on my hands ?? I have been doing some housekeeping, cleaning up code.

    I’ll double check this.

    Thanks for raising it

    Thread Starter Simon

    (@simonfricker)

    Thank you 123host!. Please release a fix to this as soon as possible.

    It would also be helpful to have a unique ID for field that is generated – although not vital.

    Plugin Author SpeakOut!

    (@123host)

    Can you elaborate on what element needs a unique ID?

    Thread Starter Simon

    (@simonfricker)

    Ideally all of the elements that are created.

    The form inputs should also be wrapped in a div to make them easier to move.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘do_shortcode not working outside of the_content’ is closed to new replies.