WordPress.org

Ready to get started?Download WordPress

Forums

Shortcode moving to top of entry content (2 posts)

  1. clarklab
    Member
    Posted 4 years ago #

    I've made a custom gallery shortcode that loads all the attached images for a post and everything seems to be working fine except that the shortcode won't stay put within the entry content. No matter where I enter the shortcode when authoring a post all the returned images shows at the top of the post.

    The other shortcodes I've made execute in-place and leave the output code in the same place the original shortcode was placed. Anyone have any ideas what would cause this one to move itself to the top?

  2. clarklab
    Member
    Posted 4 years ago #

    Found the problem. My function echoed out a bunch of content and instead I had to save all the content as variables and use a return.

    so instead of:

    echo "content";
    echo "other content";

    it became

    $variable.="content";
    $variable.=" other content";
    return $variable

Topic Closed

This topic has been closed to new replies.

About this Topic