[wp-trac] [WordPress Trac] #51542: is_home() returns true for any component of an XML Sitemap

WordPress Trac noreply at wordpress.org
Mon Feb 28 18:51:06 UTC 2022


#51542: is_home() returns true for any component of an XML Sitemap
--------------------------+------------------------------
 Reporter:  MadtownLems   |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Sitemaps      |     Version:
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by RavanH):

 Not sure this should be seen as a duplicate of #51117. Sure the default
 main query will set the is_home flag but when I modify the main query
 arguments (with query filter) to match the dedicated posts sitemap query,
 the is_home flag still gets set.

 I checked and this is because of the following lines in wp-includes/class-
 wp-query.php starting at line 992:
 {{{#!php
 if ( ! ( $this->is_singular || $this->is_archive || $this->is_search ||
 $this->is_feed
                 || ( defined( 'REST_REQUEST' ) && REST_REQUEST &&
 $this->is_main_query() )
                 || $this->is_trackback || $this->is_404 || $this->is_admin
 || $this->is_robots || $this->is_favicon ) ) {
         $this->is_home = true;
 }
 }}}
 where the is_home flag is set when no others apply.

 It seems to me we need a is_sitemap flag, in which case #51543 is more
 related :)

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/51542#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list