[wp-trac] [WordPress Trac] #51860: wp-sitemap includes empty post entries returned by filters

WordPress Trac noreply at wordpress.org
Wed Nov 25 16:13:44 UTC 2020


#51860: wp-sitemap includes empty post entries returned by filters
-------------------------+------------------------------
 Reporter:  jsmoriss     |       Owner:  (none)
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Sitemaps     |     Version:  5.5
 Severity:  normal       |  Resolution:
 Keywords:               |     Focuses:
-------------------------+------------------------------

Comment (by jsmoriss):

 Replying to [comment:4 Cybr]:
 > I faced the same issue; discussed at Slack
 https://wordpress.slack.com/archives/CTKTGNJJW/p1604995479019700.
 >
 > A proper workaround to this would be to maintain an active cache with
 page/term/author IDs you wish to exclude. Then, inject those into the
 query as exclusions. However, this is not an easy feat since WordPress is
 quite dynamic.
 >
 > I believe Yoast SEO provides such a system with "Indexables," something
 that's challenging to incorporate and maintain.

 I see you faced the same issue I did. I believe I found a working solution
 by using a static cache variable to create the exclusion list once per
 page load. Since XML sitemaps are not retrieved as often as a PHP webpage,
 this is probably fine, but for maximum performance, I would consider
 storing the exclusion list in transient cache and hooking a 'clear cache'
 action to clear the exclusion list transient when posts, terms, or users
 are updated.

 https://github.com/SurniaUlula/wpsso/blob/master/lib/wp-sitemaps.php

 js.

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


More information about the wp-trac mailing list