apply_filters( 'wp_sitemaps_posts_query_args', array $args, string $post_type )

Filters the query arguments for post type sitemap queries.


Description

Top ↑

See also

  • WP_Query: for a full list of arguments.

Top ↑

Parameters

$args array
Array of WP_Query arguments.
$post_type string
Post type name.

Top ↑

Source

File: wp-includes/sitemaps/providers/class-wp-sitemaps-posts.php. View all references

$args = apply_filters(
	'wp_sitemaps_posts_query_args',
	array(
		'orderby'                => 'ID',
		'order'                  => 'ASC',
		'post_type'              => $post_type,
		'posts_per_page'         => wp_sitemaps_get_max_urls( $this->object_type ),
		'post_status'            => array( 'publish' ),
		'no_found_rows'          => true,
		'update_post_term_cache' => false,
		'update_post_meta_cache' => false,
	),
	$post_type
);


Top ↑

Changelog

Changelog
Version Description
5.5.0 Introduced.

Top ↑

User Contributed Notes

  1. Skip to note 1 content

    Filters the custom query arguments for post-type sitemap queries.

    add_filter( 'wp_sitemaps_posts_query_args', 'wpdocs_sitemaps_posts_query_args_callback', 10, 2 );
    
    function wpdocs_sitemaps_posts_query_args_callback( $args, $post_type ) {
    	$post_type = 'post_type_name'; // your post type
    
    	$args = array(
    		'post_type'   => $post_type,
    		'order'       => 'desc',
    		'post_status' => array( 'publish' ),
    		'meta_query'  => array(
    			'relation' => 'AND',
    			array(
    				'key'     => 'some_key_name',
    				'value'   => 'some_value',
    				'compare' => 'LIKE',
    			),
    			array(
    				'key'     => 'some_key_name_2',
    				'value'   => 'some_value_2',
    				'compare' => '>=',
    			),
    		),
    	);
    
    	return $args;
    }

You must log in before being able to contribute a note or feedback.