Title: wp_is_xml_request
Published: May 7, 2019
Last modified: February 24, 2026

---

# wp_is_xml_request(): bool

## In this article

 * [Return](https://developer.wordpress.org/reference/functions/wp_is_xml_request/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_is_xml_request/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_is_xml_request/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_is_xml_request/?output_format=md#changelog)

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

Checks whether current request is an XML request, or is expecting an XML response.

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

 bool True if `Accepts` or `Content-Type` headers contain `text/xml` or one of the
related MIME types. False otherwise.

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

    ```php
    function wp_is_xml_request() {
    	$accepted = array(
    		'text/xml',
    		'application/rss+xml',
    		'application/atom+xml',
    		'application/rdf+xml',
    		'text/xml+oembed',
    		'application/xml+oembed',
    	);

    	if ( isset( $_SERVER['HTTP_ACCEPT'] ) ) {
    		foreach ( $accepted as $type ) {
    			if ( str_contains( $_SERVER['HTTP_ACCEPT'], $type ) ) {
    				return true;
    			}
    		}
    	}

    	if ( isset( $_SERVER['CONTENT_TYPE'] ) && in_array( $_SERVER['CONTENT_TYPE'], $accepted, true ) ) {
    		return true;
    	}

    	return false;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/load.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/load.php#L1980)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/load.php#L1980-L2003)

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

| Used by | Description | 
| [wp_die()](https://developer.wordpress.org/reference/functions/wp_die/)`wp-includes/functions.php` |

Kills WordPress execution and displays HTML page with an error message.

  |

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

| Version | Description | 
| [5.2.0](https://developer.wordpress.org/reference/since/5.2.0/) | Introduced. |

## User Contributed Notes

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