Make a Shortcode load after Post/Page Content?

I created a shortcode for time.ly‘s “all in one event calendar app” that makes a paginated list of upcoming events with out all the java script and user options.

I posted about it here. (Its still a work in progress)

As it is now it loads before all the content, I’m guessing because the file returned at the end includes echo‘s. I’d prefer if it always loaded after the posted content regardless of where it is typed on the page. Is it possible to force a short code to load after page content?

Solutions Collecting From Web of "Make a Shortcode load after Post/Page Content?"

The contents of a shortcode should always be returned rather than echoed. You can read more about shortcode output on the Codex.

A while ago, I asked a question about “How to Return Loop Contents” that might prove useful in this situation.

You could use ajax to fetch the content after the page loads, then insert it into the dom where you want it.

Here are some links that should help:

http://codex.wordpress.org/AJAX

http://codex.wordpress.org/AJAX_in_Plugins

http://www.garyc40.com/2010/03/5-tips-for-using-ajax-in-wordpress/

HTH

Just run do_shortcode($returned_content) from the plugin, and it will run all shortcode filters on the content.

i.e.

Plugin: MyPlugin.php

function some_func(){
     $data = "[tabs][tab]Tabbed content here[/tab][/tabs]";
     return $data;    
 }

The above function will return the data literally. without the shortcodes being parsed. If you want to parse the shortcodes for display, simply do this:

function some_func(){
     $data = "[tabs][tab]Tabbed content here[/tab][/tabs]";
     return do_shortcode($data);    
 }

This example will parse the shortcodes before return.