Văn Cao Trần
Văn Cao Trần

Reputation: 117

WordPress short code position

I am learning to write a WordPress short code.

In my function I created a big table and some CSS. When I put my short code into posts, the position of the table is always on the top of the posts, regardless of where I put the code in the editor.

How can I fix this?

Upvotes: 0

Views: 85

Answers (1)

Vel
Vel

Reputation: 9317

Shortcode content should be return. not echo. user below:

    function shortcodetest(){   
        return "<table><tr><td>test</td></tr></table>";
    }
    add_shortcode("shortcode","shortcodetest");

Do not use echo :

    function shortcodetest(){   
        echo  "<table><tr><td>test</td></tr></table>";
    }
    add_shortcode("shortcode","shortcodetest");

Upvotes: 1

Related Questions