Support » Plugin: SiteTree » Bug – site map is appended to the_content in secondary queries

  • Resolved Chase Wiseman


    When the plugin appends the site map to the content of the Archive Page (from the SiteTree Dashboard settings), via the the_content filter, it also appends it to any other custom queries on that page who’s loop uses the_content().

    Steps to reproduce:

    1. Take any theme that has a custom secondary loop (created correctly via a new WP_Query) that uses the_content(), whether it be in the header, footer, or custom page template.
    2. Set that page to be the Archive Page via the SiteTree Dashboard.
    3. View the page and notice that the site map is appended to the secondary query’s the_content filter along with the correct page’s the_content.

    Possible fix:
    Either the SiteTree class’s filter_page_request or append_sitemap methods need a check for is_main_query() or something similar to make sure you’re not messing with custom loops.

    Great post by Pippin on the subject:

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Luigi


    I was hoping it didn’t pop up before the next release but here we are.

    Due to the kind of bug and the page where it turns on, it goes almost under the category of Edge Cases, so, I piled the fix on those that will be included in version 1.6.

    Thank you anyway for the report.

    P.S. The WP_Query class is just one of the tools to create multiple Loops, not always the best choice.

    Plugin Author Luigi


    It’s some time, now, that I have decided there will not be further updates in the near future. For the few people that might have awaken the behaviour over-detailed above, the code down here is the workaround.

    # Replace the function SiteTree::append_sitemap(), defined in
    # sitetree/core/sitetree.class.php, with this one.
    public function append_sitemap( $the_content ) {
      if ( in_the_loop() ) {
        // Paste here the body, without return value, of
        // the old version of SiteTree::append_sitemap()
      return $the_content;

    Just an aside: when the plugin behaves as described, it is very likely that usability hasn’t been taken enough into consideration, and that the real bug to be fixed might be already there, in the organisation of the content.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Bug – site map is appended to the_content in secondary queries’ is closed to new replies.