---
title: Filter HTML sitemap query
url: "https://www.seopress.org/support/hooks/filter-html-sitemap-query/"
lang: en-US
updated: 2021-09-29
hook_name: seopress_sitemaps_html_query
required_version: 2.4
---

# Filter HTML sitemap query

- **Hook name:** `seopress_sitemaps_html_query`
- **Required version:** 2.4

```php
function sp_sitemaps_html_query($args, $cpt_key) { 
	//Default Query 
	//$args = array('posts_per_page' => 1000,'order'=> $seopress_xml_sitemap_html_order_option,'orderby' => $seopress_xml_sitemap_html_orderby_option,'post_type' => $cpt_key,'post_status' => 'publish','meta_query' => array( array( 'key' => '_seopress_robots_index', 'value' => 'yes', 'compare' => 'NOT EXISTS' ) ),'fields' => 'ids','exclude' => $seopress_xml_sitemap_html_exclude_option,'suppress_filters' => false); 
	if ($cpt_key =='page') { //If page post type, order page by admin menu order $args['order'] = 'ASC'; 
		$args['orderby'] = 'menu_order'; 
		return $args; 
	} else {
		return $args;
	}
}
add_filter('seopress_sitemaps_html_query', 'sp_sitemaps_html_query', 10, 2);
```

Source: [https://gist.github.com/wp-seopress/1be43a5fc43ee346685d4431ca38db8f](https://gist.github.com/wp-seopress/1be43a5fc43ee346685d4431ca38db8f)



