short code output too early

A shortcode has to return just a string, you should not print something like in wp_list_pages() or echo. From Shortcode API:

The return value of a shortcode handler function is inserted into the post content output in place of the shortcode macro. Remember to use return and not echo – anything that is echoed will be output to the browser, but it won’t appear in the correct place on the page.

Leave a Comment