WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For some reason, my posts content (the content placed outside of the shortcodes I have set up) is only displaying below all the shortcodes, no matter where I place content in the post.

For example, I could set up a post like this:

[boxes cat="Features"]

test content here

[boxes cat="Reviews"]

And the test content will display below the Features AND the Reviews. Why would it do that? Some of my shortcodes use the php include. Here's an example of one of my shortcodes:

function free_ms_cms( $atts, $content = null ) {
   $free_ms = TEMPLATEPATH . '/get-free-ms.php';
add_shortcode( 'free-ms', 'free_ms_cms' );

Anyone able to help? Thanks!

share|improve this question
up vote 4 down vote accepted

Are your shortcodes setup correctly? This usually means that your shortcode handling is echoing the shortcode content instead of returning it as a string.

For your case, while you are including a file in your shortcode, I doubt that you have the file setup to return the output instead of echo'ing it.

Try this instead:

function free_ms_cms( $atts, $content = null ) {
   $free_ms = TEMPLATEPATH . '/get-free-ms.php';
   ob_start(); //start an output buffer to capture any output
   return ob_get_clean(); //return the current buffer and clear it
add_shortcode( 'free-ms', 'free_ms_cms' );
share|improve this answer
My shortcodes are using include, I updated my question with one of my shortcodes. I'm not sure if it returns or echoes with include. If you could check it out and update your answer I would greatly appreciate it. Thanks! – Jared Feb 18 '11 at 3:34
I know what you mean now, I've solved my own question with your help. :) – Jared Feb 18 '11 at 4:04
@Jared: post the solution as an answer for future lurking guests. – Bainternet Feb 18 '11 at 7:49
@Jared, I've updated the answer to include code for your particular instance. – prettyboymp Feb 18 '11 at 13:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.