Title: WP_Sitemaps_Stylesheet::render_stylesheet
Published: August 11, 2020
Last modified: May 20, 2026

---

# WP_Sitemaps_Stylesheet::render_stylesheet( string $type )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_sitemaps_stylesheet/render_stylesheet/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/classes/wp_sitemaps_stylesheet/render_stylesheet/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_sitemaps_stylesheet/render_stylesheet/?output_format=md#related)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_sitemaps_stylesheet/render_stylesheet/?output_format=md#wp--skip-link--target)

Renders the XSL stylesheet depending on whether it’s the sitemap index or not.

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

 `$type`stringrequired

Stylesheet type. Either `'sitemap'` or `'index'`.

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

    ```php
    public function render_stylesheet( $type ) {
    	header( 'Content-Type: application/xml; charset=UTF-8' );

    	if ( 'sitemap' === $type ) {
    		// All content is escaped below.
    		echo $this->get_sitemap_stylesheet();
    	}

    	if ( 'index' === $type ) {
    		// All content is escaped below.
    		echo $this->get_sitemap_index_stylesheet();
    	}

    	exit;
    }
    ```

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

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

| Uses | Description | 
| [WP_Sitemaps_Stylesheet::get_sitemap_stylesheet()](https://developer.wordpress.org/reference/classes/wp_sitemaps_stylesheet/get_sitemap_stylesheet/)`wp-includes/sitemaps/class-wp-sitemaps-stylesheet.php` |

Returns the escaped XSL for all sitemaps, except index.

  | 
| [WP_Sitemaps_Stylesheet::get_sitemap_index_stylesheet()](https://developer.wordpress.org/reference/classes/wp_sitemaps_stylesheet/get_sitemap_index_stylesheet/)`wp-includes/sitemaps/class-wp-sitemaps-stylesheet.php` |

Returns the escaped XSL for the index sitemaps.

  |

## User Contributed Notes

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