Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #26873

    Hi,

    I created a simple shortcode and when I put it in a text block in builder it renders *above* the slider, right after div id=”main”. It happens even with a very simple shortcode:

    function example_shortcode() {
    echo "Test";
    }
    add_shortcode( 'example_shortcode', 'example');

    You can see the issue here:

    Shortcode in textblock: http://www.imm.io/1dYz0

    Rendering of the shortcode in the frontend: http://www.imm.io/1dYzu

    #131919

    Hi vinko

    You should be using return inside the function. Example:

    // Add Shortcode
    function my_custom_shortcode() {

    // Code
    return 'example';
    }
    add_shortcode( 'example', 'my_custom_shortcode' );

    Which should work correctly. Another example but with enclosing:

    // Add Shortcode
    function bold_text_shortcode( $atts , $content = null ) {

    // Code
    return '<strong>' . $content . '</strong>';

    }
    add_shortcode( 'b', 'bold_text_shortcode' );

    Regards,

    Devin

    #131920

    Well, that’s how we beginners learn! Thank you very much!

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Shortcode in text block in builder – very strange problem’ is closed to new replies.