---
title: Filtrar consulta de tipo de contenido en el mapa del sitio XML
url: "https://www.seopress.org/es/soporte/hooks/filtrar-consulta-de-tipo-de-contenido-en-el-mapa-del-sitio-xml/"
lang: es
updated: 2023-04-21
hook_name: seopress_sitemaps_single_query
required_version: 2.4
---

# Filtrar consulta de tipo de contenido en el mapa del sitio XML

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

```php
function sp_sitemaps_single_query($args, $cpt_key) { 
	//Default Query 
	//$args = array( 'posts_per_page' => 1000, 'order'=> 'DESC', 'orderby' => 'modified', 'post_type' => $cpt_key, 'post_status' => 'publish', 'meta_query' => ['relation' => 'OR', ['key' => '_seopress_robots_index','value' => '','compare' => 'NOT EXISTS'],['key'=>'_seopress_robots_index','value' => 'yes','compare' => '!=']], 'fields' => 'ids', 'lang' => '', 'has_password' => false ); 
	if ($cpt_key == 'page') { //If Page XML Sitemap, change posts_per_page value to 100 
		$args['posts_per_page'] = '100';
		return $args;
	} else { 
		return $args;
	}
}
add_filter('seopress_sitemaps_single_query', 'sp_sitemaps_single_query', 10, 2);


//Get singular post type XML sitemaps for a specific language with Polylang
//e.g.: https://www.example.com/page-sitemap1.xml?lang=fr to generate the Page XML sitemap for French content only
function sp_sitemaps_single_query($args, $cpt_key) { 
	if (isset($_GET['lang']) && sanitize_key($_GET['lang'])) {
		$args['lang'] = esc_html($_GET['lang']);
	}
	return $args;
}
add_filter('seopress_sitemaps_single_query', 'sp_sitemaps_single_query', 10, 2);
```

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


 

Para usar con: [seopress\_sitemaps\_max\_posts\_per\_sitemap](https://www.seopress.org/es/soporte/hooks/filtrar-el-numero-maximo-de-publicaciones-por-mapa-del-sitio-paginado/)
