Site logo

[Resolved] Basic Shortcode Not Rendering Inside Section

Home Forums Support [Resolved] Basic Shortcode Not Rendering Inside Section

Home Forums Support Basic Shortcode Not Rendering Inside Section

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #237797
    Beau

    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?

    #237825
    Tom
    Lead Developer
    Lead Developer

    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 🙂

    #238524
    Beau

    Man you’re good! Works like a charm – thanks again!!

    #238553
    Tom
    Lead Developer
    Lead Developer

    You’re welcome 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.