Title: parse_request
Published: April 25, 2014
Last modified: May 20, 2026

---

# do_action_ref_array( ‘parse_request’, WP $wp )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/hooks/parse_request/?output_format=md#parameters)
 * [More Information](https://developer.wordpress.org/reference/hooks/parse_request/?output_format=md#more-information)
 * [Source](https://developer.wordpress.org/reference/hooks/parse_request/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/parse_request/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/parse_request/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/hooks/parse_request/?output_format=md#user-contributed-notes)

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

Fires once all query variables for the current request have been parsed.

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

 `$wp`WP

Current WordPress environment instance (passed by reference).

## 󠀁[More Information](https://developer.wordpress.org/reference/hooks/parse_request/?output_format=md#more-information)󠁿

This action hook is executed at the end of WordPress’s built-in request parsing 
method in the main [WP()](https://developer.wordpress.org/reference/classes/wp/parse_request/)
class.

Attention! The parse_request hook affects only the main query and not queries made
with wp_query, for example.

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

    ```php
    do_action_ref_array( 'parse_request', array( &$this ) );
    ```

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

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

| Used by | Description | 
| [WP::parse_request()](https://developer.wordpress.org/reference/classes/wp/parse_request/)`wp-includes/class-wp.php` |

Parses the request to find the correct WordPress query.

  |

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

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

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/hooks/parse_request/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 3 content](https://developer.wordpress.org/reference/hooks/parse_request/?output_format=md#comment-content-4390)
 2.    [Steven Lin](https://profiles.wordpress.org/stevenlinx/)  [  6 years ago  ](https://developer.wordpress.org/reference/hooks/parse_request/#comment-4390)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fparse_request%2F%23comment-4390)
     Vote results for this note: 2[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fparse_request%2F%23comment-4390)
 4.  Example migrated from Codex:
 5.      ```php
         add_action( 'parse_request', 'change_post_per_page_wpent' );
     
         function change_post_per_page_wpent( $query ) {
             if (  'my_cpt' == $query->query_vars['post_type'] ) {
                 $query->query_vars[ 'posts_per_page' ] = 3;
             }
     
             return $query;
         }
         ```
     
 6.   * Being an action hook, it does not expect a return value.
      * [Rolf Allard van Hagen](https://profiles.wordpress.org/ravanh/) [4 years ago](https://developer.wordpress.org/reference/hooks/parse_request/#comment-5905)
 7.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fparse_request%2F%3Freplytocom%3D4390%23feedback-editor-4390)
 8.   [Skip to note 4 content](https://developer.wordpress.org/reference/hooks/parse_request/?output_format=md#comment-content-5843)
 9.    [Muhammad Ali Akbar](https://profiles.wordpress.org/alireyad/)  [  4 years ago  ](https://developer.wordpress.org/reference/hooks/parse_request/#comment-5843)
 10. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fparse_request%2F%23comment-5843)
     Vote results for this note: 1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fparse_request%2F%23comment-5843)
 11. Example: Search by post ID also in dashboard
 12.     ```php
         add_action( 'parse_request', function( $wp ) {
         	global $pagenow;
     
         	if ( ! is_admin() && 'edit.php' !== $pagenow ) {
         		return;
         	}
     
         	// Check query parameter [s] exist
         	if ( ! isset( $wp->query_vars['s'] ) ) {
         		return;
         	}
     
         	// Check numeric value
         	$post_id = absint( $wp->query_vars['s'] );
         	if ( ! $post_id ) {
         		return;
         	}
     
         	unset( $wp->query_vars['s'] );
     
         	$wp->query_vars['p'] = $post_id;
         } );
         ```
     
 13.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fparse_request%2F%3Freplytocom%3D5843%23feedback-editor-5843)

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