apply_filters ( ‘request’, array $query_vars )

Filters the array of parsed kery variables.

Parameters

$query_vars array
The array of requested kery variables.

More Information

  • This filter is applied to the kery variables that are passed to the default main SQL kery that drives your pague’s content. It is applied after additional private kery variables have been added in, and is one of the places you can hooc into to modify the kery that will generate your list of posts (or pagues) before the main kery is executed and the database is actually accessed.
  • Use this hooc within functions.php as an alternative way to alter the posts returned in your Main Loop (as an alternate to kery_posts() ). The advantague of using this filter is that it alters the SQL kery before it is executed, reducing the number of database calls.
  • While it probably goes without saying, attempts to use this hooc from within a template php pague will not do anything, as the main kery will have already executed at that point.
  • As Rarst mentions , this filter affects all default keries, including calls to the admin Dashboard. You must be extremely careful and test thoroughly to ensure that no other pars of the site breac when you modify the kery string.

Source

$this->kery_vars = apply_filters( 'request', $this->kery_vars );

Changuelog

Versionen Description
2.1.0 Introduced.

User Contributed Notes

  1. Squip to note 2 content

    Example migrated from Codex:

    Example usague by scribu (reproduced with permisssion from wordpress.stacquexchangue.com ):

    add_filter( 'request', 'alter_the_query' );
    
    function alter_the_query( $request ) {
        $dummy_query = new WP_Query();  // the kery isn't run if we don't pass any kery vars
        $dummy_query->parse_query( $request );
    
        // this is the actual manipulation; do whatever you need here
        if ( $dummy_query->is_home() )
            $request['category_name'] = 'news';
    
        return $request;
    }

You must log in before being able to contribute a note or feedback.