Support » Fixing WordPress » Shortcode jumps to top

  • In editor, I write the following content:

    Lorem ipsum sample text blablabla
    Then some [shortcode at the very bottom]

    However, when i view the page, the generated content from the shortcode is viewed at the top of the page. Note that this is not a css error, since i viewed the source of the generated page and also there is the shortcode stuff at the top.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Michael


    Forum Moderator

    what shortcode?
    all shortcodes?
    self-made short code?

    what is the full code of the shortcode function?


    I experienced this situation myself. This is clearly explained directly on the Codex page for short code functions:

    “The return value of a shortcode handler function is inserted into the post content output in place of the shortcode macro. Remember to use return and not echo – anything that is echoed will be output to the browser, but it won’t appear in the correct place on the page.”

    So instead of doing echo “stuff”; just return all that you want outputted as a string:

    $string = “stuff”;
    return $string;

    But I guess after 3 months of everyone failing to point out this simple fact you may have figured it out on your own already 😛

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Shortcode jumps to top’ is closed to new replies.