Title: WP_Sitemaps_Taxonomies::get_url_list
Published: August 11, 2020
Last modified: August 20, 2026

---

# WP_Sitemaps_Taxonomies::get_url_list( int $page_num, string $object_subtype = ” ): array[]

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_sitemaps_taxonomies/get_url_list/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_sitemaps_taxonomies/get_url_list/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_sitemaps_taxonomies/get_url_list/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/classes/wp_sitemaps_taxonomies/get_url_list/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/classes/wp_sitemaps_taxonomies/get_url_list/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_sitemaps_taxonomies/get_url_list/?output_format=md#changelog)

Gets a URL list for a taxonomy sitemap.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_sitemaps_taxonomies/get_url_list/?output_format=md#parameters)󠁿

 `$page_num`intrequired

Page of results.

`$object_subtype`stringoptional

Taxonomy name.

Default:`''`

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_sitemaps_taxonomies/get_url_list/?output_format=md#return)󠁿

 array[] Array of URL information for a sitemap.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_sitemaps_taxonomies/get_url_list/?output_format=md#source)󠁿

    ```php
    public function get_url_list( $page_num, $object_subtype = '' ) {
    	// Restores the more descriptive, specific name for use within this method.
    	$taxonomy = $object_subtype;

    	$supported_types = $this->get_object_subtypes();

    	// Bail early if the queried taxonomy is not supported.
    	if ( ! isset( $supported_types[ $taxonomy ] ) ) {
    		return array();
    	}

    	/**
    	 * Filters the taxonomies URL list before it is generated.
    	 *
    	 * Returning a non-null value will effectively short-circuit the generation,
    	 * returning that value instead.
    	 *
    	 * @since 5.5.0
    	 *
    	 * @param array[]|null $url_list The URL list. Default null.
    	 * @param string       $taxonomy Taxonomy name.
    	 * @param int          $page_num Page of results.
    	 */
    	$url_list = apply_filters(
    		'wp_sitemaps_taxonomies_pre_url_list',
    		null,
    		$taxonomy,
    		$page_num
    	);

    	if ( null !== $url_list ) {
    		return $url_list;
    	}

    	$url_list = array();

    	// Offset by how many terms should be included in previous pages.
    	$offset = ( $page_num - 1 ) * wp_sitemaps_get_max_urls( $this->object_type );

    	$args           = $this->get_taxonomies_query_args( $taxonomy );
    	$args['fields'] = 'all';
    	$args['offset'] = $offset;

    	$taxonomy_terms = new WP_Term_Query( $args );

    	if ( ! empty( $taxonomy_terms->terms ) ) {
    		foreach ( $taxonomy_terms->terms as $term ) {
    			$term_link = get_term_link( $term, $taxonomy );

    			if ( is_wp_error( $term_link ) ) {
    				continue;
    			}

    			$sitemap_entry = array(
    				'loc' => $term_link,
    			);

    			/**
    			 * Filters the sitemap entry for an individual term.
    			 *
    			 * @since 5.5.0
    			 * @since 6.0.0 Added `$term` argument containing the term object.
    			 *
    			 * @param array   $sitemap_entry Sitemap entry for the term.
    			 * @param int     $term_id       Term ID.
    			 * @param string  $taxonomy      Taxonomy name.
    			 * @param WP_Term $term          Term object.
    			 */
    			$sitemap_entry = apply_filters( 'wp_sitemaps_taxonomies_entry', $sitemap_entry, $term->term_id, $taxonomy, $term );
    			$url_list[]    = $sitemap_entry;
    		}
    	}

    	return $url_list;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/sitemaps/providers/class-wp-sitemaps-taxonomies.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/sitemaps/providers/class-wp-sitemaps-taxonomies.php#L61)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/sitemaps/providers/class-wp-sitemaps-taxonomies.php#L61-L135)

## 󠀁[Hooks](https://developer.wordpress.org/reference/classes/wp_sitemaps_taxonomies/get_url_list/?output_format=md#hooks)󠁿

 [apply_filters( ‘wp_sitemaps_taxonomies_entry’, array $sitemap_entry, int $term_id, string $taxonomy, WP_Term $term )](https://developer.wordpress.org/reference/hooks/wp_sitemaps_taxonomies_entry/)

Filters the sitemap entry for an individual term.

 [apply_filters( ‘wp_sitemaps_taxonomies_pre_url_list’, array[]|null $url_list, string $taxonomy, int $page_num )](https://developer.wordpress.org/reference/hooks/wp_sitemaps_taxonomies_pre_url_list/)

Filters the taxonomies URL list before it is generated.

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_sitemaps_taxonomies/get_url_list/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_sitemaps_get_max_urls()](https://developer.wordpress.org/reference/functions/wp_sitemaps_get_max_urls/)`wp-includes/sitemaps.php` |

Gets the maximum number of URLs for a sitemap.

  | 
| [WP_Sitemaps_Taxonomies::get_object_subtypes()](https://developer.wordpress.org/reference/classes/wp_sitemaps_taxonomies/get_object_subtypes/)`wp-includes/sitemaps/providers/class-wp-sitemaps-taxonomies.php` |

Returns all public, registered taxonomies.

  | 
| [WP_Sitemaps_Taxonomies::get_taxonomies_query_args()](https://developer.wordpress.org/reference/classes/wp_sitemaps_taxonomies/get_taxonomies_query_args/)`wp-includes/sitemaps/providers/class-wp-sitemaps-taxonomies.php` |

Returns the query args for retrieving taxonomy terms to list in the sitemap.

  | 
| [WP_Term_Query::__construct()](https://developer.wordpress.org/reference/classes/wp_term_query/__construct/)`wp-includes/class-wp-term-query.php` |

Constructor.

  | 
| [get_term_link()](https://developer.wordpress.org/reference/functions/get_term_link/)`wp-includes/taxonomy.php` |

Generates a permalink for a taxonomy term archive.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  | 
| [is_wp_error()](https://developer.wordpress.org/reference/functions/is_wp_error/)`wp-includes/load.php` |

Checks whether the given variable is a WordPress Error.

  |

[Show 2 more](https://developer.wordpress.org/reference/classes/wp_sitemaps_taxonomies/get_url_list/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_sitemaps_taxonomies/get_url_list/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_sitemaps_taxonomies/get_url_list/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.9.0](https://developer.wordpress.org/reference/since/5.9.0/) | Renamed `$taxonomy` to `$object_subtype` to match parent class for PHP 8 named parameter support. | 
| [5.5.0](https://developer.wordpress.org/reference/since/5.5.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_sitemaps_taxonomies%2Fget_url_list%2F)
before being able to contribute a note or feedback.