WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Plugin API/Action Reference/parse request

This page is marked as incomplete. You can help Codex by expanding it.

Description

This action hook is executed at the end of WordPress's built-in request parsing method in the main WP() class.

Attention! Parse Request affects only the main query not queries made with wp_query, for example.

Example Usage

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;
}

Source File

The 'parse_request' hook is found in /wp-includes/class-wp.php, within the parse_request() method of the WP() class.

Related

  • Action: parse_request
  • Filter: request