JonnyBorg JonnyBorg - 18 days ago 6
HTML Question

WordPress Shortcode thrown outside WYSIWYG html DIV

I'm trying to put a shortcode within my page via the Wordpress Page WYSIWYG editor in a specific

<div>
element. The shortcode does appear and works. But instead of staying within my
<div>
, when the page renders it does not render in the
<div>
but instead near the top of my page, leading the pages content instead.

Any ideas as to how to prevent this?

I am not trying to put it within the pages template. I'm trying to place it within simple custom html, laid out within the Pages WYSIWYG editor.

E.g. I'm placing the shortcode with in the page like so:

<div class="row">
<p>some custom page html content</p>
<div>
<div class="row">
[some_shortcode]
</div>
<div class="row">
<p>some custom page html content</p>
<div>
<div class="row">
<p>some custom page html content</p>
<div>


Instead it renders like this:

<!-- THE SHORTCODES HTML APPEARS HERE and Works but not where I wanted it. -->
<!-- then the rest of the pages html content -->
<div class="row">
<p>some custom page html content</p>
<div>
<div class="row"><!-- no more shortcode-->
</div>
<div class="row">
<p>some custom page html content</p>
<div>
<div class="row">
<p>some custom page html content</p>
<div>

Answer

This problem occurs whenever a plugin is printing out its contents instead of using return.

See the Shortcode API docs for more information; http://codex.wordpress.org/Shortcode_API#Output