Archived topic
Basic Shortcode Not Rendering Inside Section
3 replies · Started by Beau on October 21, 2016
At this point, I'm just testing a very simple shortcode to bring some text on a full width banner section on the homepage. Eventually it will be used to bring in custom code for styling Advanced Custom Fields.
URL - http://staging.wheelsnwaves.com/
Here's the code I have in my child theme's functions.php file:
function test_function() {
echo "TEST";
}
add_shortcode('test', 'test_function');
The shortcode prints the text, but it ends up outside of the section. Thoughts?
You'll want to use ob_start() and ob_get_clean().
For example, can the "Output" section of this page: https://codex.wordpress.org/Shortcode_API
Let me know if you need more info :)
Man you're good! Works like a charm - thanks again!!
You're welcome :)