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

Currently I have a short that embeds a div into the the_content. This works fine like thus:

[shortcode param=1 param=2]

This returns a message at the end of the post, but within the current article, however instead of being:


I'm looking to produce:


Is this possible, and what functions do I need use? I've already tried using add_filter and apply_filter but they went into a infinite loop instead of:

return $message.


share|improve this question
Your shortcode already appears to do what the title of the question is asking. Nor is the title describing what you're actually asking. Please ammend the title – Tom J Nowell Aug 26 '12 at 17:45
Thanks for accepting, I hope you manage to implement what you need – Tom J Nowell Aug 26 '12 at 20:48
up vote 2 down vote accepted

What your asking for can't be done using shortcodes. <article> isn't a part of the content, its part of the theme and it 'contains' the content. Thus shortcodes cannot modify it or move those tags around. Shortcodes by definition are part of the content, so anything they add on the end is also a part of the content.

Instead you will need to modify your theme to add the extra elements somewhere else. How this is done is beyond the scope of this question/answer, but I advise using post meta ( and metaboxes to provide a UI )

To demonstrate the irrationality of what you're requesting:

  <?php the_content(); ?>
<!-- you want the_content() to magically reach over here via a shortcode and do something --!>

Instead, something along these lines:

  <?php the_content(); ?>
$meta = get_post_meta($post->ID,'_dothing',true);
if($meta == true){
    $param1 = get_post_meta($post->ID,'_dothing_param1',true);
    $param2= get_post_meta($post->ID,'_dothing_param2',true);
share|improve this answer

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.