• Hi:
    I built a plugin that lets you insert a form that contains only a button, but when I insert the shortcode in a page, it is always displaying in the top-left corner of my page. I’ve scanned the forums and seen other with this issue, but none of the shortcodes displayed forms, and none of the solutions worked for me.
    I’m not initializing my shortcode in the init file, but rather have a separate shortcodes PHP file because I need to do a great deal of DB work to make the form work (which it does), it just will not display correctly.

    Here is my code that displays the shortcode:

    <div id="tclaunchform">
    <form method="post">
    <input type="submit" onClick="window.open(document.getElementById('results<?php echo $id;?>').innerHTML);" value="Show Results" class='button'/>
    </form>
    </div>

    NOTE: “results” is a hidden DIV and I have styled the tclaunchform DIV (only padding around it).

    I have also tried this in multiple Themes with now change in the symptom.

    Any help would be great here. I’ve been rooting through this for 2 days and an at my end now.

    Best Regards,
    Dennis Hall

Viewing 1 replies (of 1 total)
  • Thread Starter dennishall

    (@dennishall)

    I finally figured it out…

    ob_start(); //Absolute must use!!!
    ...put any HTML, JS, CSS, PHP... whatever you want in here!!!
    $content = ob_get_clean(); //Absolute must use!!!
    return $content; //Absolute must use!!!

    Using the ob start, get_clean, the returning the content works with any shortcode – I just tested it with all kinds of different shortcode scenarios and could not break it.

    Best Regards,
    Dennis Hall

Viewing 1 replies (of 1 total)

The topic ‘Shorcode does not display in correct position on page’ is closed to new replies.