Skip to content

Instantly share code, notes, and snippets.

@mrwweb
Created May 8, 2013 22:26
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mrwweb/5544153 to your computer and use it in GitHub Desktop.
Save mrwweb/5544153 to your computer and use it in GitHub Desktop.
<?php
// Resuable instance of WP_Query with preset $args
class Extended_WP_Query extends WP_Query {
function __construct( $args = array() ) {
$args = wp_parse_args( $args, array(
// some $args go here for reuse
) );
parent::__construct( $args );
}
}
// Then use this like normal WP_Query
// e.g.:
// $x = new Extended_WP_Query( $args ); while ( $x->have_posts() ) : etc...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment