Hi I have created a plugin that places a Google Translator into a text widget in WordPress. I have setup shortcode to do this – and the shortcode seems to be outputting the correct HTML, except that the HTML is not showing up INSIDE of the text widget as it should.
Here is my plugin code: http://pastebin.com/BMbnEqAW
Here is the page: http://www.richmindonline.com/test/
When I do a “View Page Source” from Firefox – I am noticing that the translator code is appearing BEFORE the text widget. So even though my shortcode is located inside of the text widget, the code shows up just above the text widget itself and is not wrapped inside of
That’s a common mistake, Shortcodes should
return values and not
Remember, the Codex is your Friend 😉
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.