I have a quick and dirty shortcode which outputs a form in my wordpress pages. However, it adds the shortcode output at the beginning of my page, instead of inline where I want it.
For example:
(WordPress post:)
This is some text!
[shortcode_here]
This is more text!
(output)
The end result does this:
Shortcode output is showing up here!
This is some text!
This is more text!
The shortcode function is simply pulling some info. from a database and echoing the formatted results, a la:
function shortcode_output() {
//get stuff from database
//format stuff
echo <<<FORM
<form method="POST" action="blah.php">
<!--more html-->
</form>
FORM;
}
I tried returning the content instead of echoing, but that simply shows up as a 0
.
You have to return html instead of echoing it. Buffer output withing your function and return it: