Skip to content
Advertisement

Plugin content always on top of post WordPress

I’m trying to make a WordPress plugin. Well, actually it’s done and fully working, except one thing.

I have added a shortcode for the plugin. But no matter where in the content I call this shortcode, the contents it gets are always on top of the post, instead of where I placed the tag.

The code that outputs something:

JavaScript

And the shortcode functionality:

JavaScript

What I want to know though, is why it is always on top of the content?

Advertisement

Answer

Your shortcode code needs to return the content, not echo it.

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement