WordPress.org

Ready to get started?Download WordPress

Forums

Advanced Sitemap Generator
[resolved] Shortcode output appears before other page text (2 posts)

  1. Eric McNiece
    Member
    Posted 1 year ago #

    Hi, thanks for sharing your work. There's an issue with the shortcode function - it's a classic mistake and easy to fix.

    Shortcodes are executed/printed before the rest of the page contents. That means if the page with the [sitemap] shortcode contains any text, it will only be displayed after the sitemap output regardless of where the shortcode is placed. That's a problem, because I wanted to put a title above the sitemap output!

    The solution is to load all of the shortcode output into a variable and return the contents instead of echoing directly in the shortcode. This way, the contents will appear in the desired location and text can be wrapped around the output.

    I've reformatted the add_shortcode() function to do precisely this. I would highly recommend switching over to this format for your future updates!

    http://pastebin.com/T7grih6W

    Best of luck :)

    http://wordpress.org/extend/plugins/advanced-sitemap-generator/

  2. Deepak Tripathi
    Member
    Plugin Contributor

    Posted 1 year ago #

    Hello,

    Thanks, i have implemented it on my new version 1.0.4


    Thanks & Regards
    Deepak Tripathi

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.