WordPress filter hook · part of WordPress core
wp_sitemaps_posts_query_args
A WordPress core filter that 5 plugins also fire themselves, running on 610+ sites between them.
How to use wp_sitemaps_posts_query_args
It's a filter: your callback receives the value and 1 more argument, and must return the (changed) value.
Add this to your theme's functions.php or a small custom plugin:
add_filter( 'wp_sitemaps_posts_query_args', function( $value, $post_type ) {
// Change $value here.
return $value;
}, 10, 2 );Argument names come from WPSSO WP Sitemaps XML with News, Image, and Video Sitemap's source. Other plugins may pass different values: check the call in the plugin you're targeting below.
This hook is fired by WordPress core too. Official reference on developer.wordpress.org →
5 plugins that fire wp_sitemaps_posts_query_args
Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.
-
WPSSO WP Sitemaps XML with News, Image, and Video Sitemap400+ installs
apply_filters( 'wp_sitemaps_posts_query_args', array( 'orderby' => 'ID', 'order' => 'ASC', 'post_type' => $post_type, 'posts_per_page' => wp_sitemaps_get_max_urls( 'post' ), 'post_status' => array( 'publish' ), 'no_found_rows' => true, 'update_post_term_cache' => false, 'update_post_meta_cache' => false, ), $post_type )lib/sitemaps/filters.php:287 -
Automatic Multilingual AI Translation by Autoglot100+ installs
apply_filters( 'wp_sitemaps_posts_query_args', array( 'orderby' => 'ID', 'order' => 'ASC', 'post_type' => $post_type, 'posts_per_page' => wp_sitemaps_get_max_urls("post"), 'post_status' => array( 'publish' ), 'no_found_rows' => true, 'update_post_term_cache' => false, 'update_post_meta_cache' => false, ), $post_type )utils/autoglot_3rdparty.php:195 -
AISA60+ installs
apply_filters( 'wp_sitemaps_posts_query_args', [ 'orderby' => 'ID', 'order' => 'ASC', 'post_type' => $type, 'posts_per_page' => $max, 'post_status' => [ 'publish' ], 'no_found_rows' => true, 'update_post_term_cache' => false, 'update_post_meta_cache' => false, 'ignore_sticky_posts' => true, ], $type )includes/seo/class-aisa-sitemap.php:482 -
Rank Authority50+ installs
apply_filters( 'wp_sitemaps_posts_query_args', [ 'orderby' => 'ID', 'order' => 'ASC', 'post_type' => 'post', 'posts_per_page' => 1, 'post_status' => ['publish'], 'no_found_rows' => true, 'update_post_term_cache' => false, 'update_post_meta_cache' => false, ], 'post' )includes/class-ra-sitemap-manager.php:2564 -
ZEISMO SEOFewer than 10 installs
apply_filters( 'wp_sitemaps_posts_query_args', $args, 'post' )includes/sitemaps-next.php:8
Need a customisation built on this hook?
Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.