Skip to content

Instantly share code, notes, and snippets.

@mattbanks
Created July 20, 2012 23:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mattbanks/3153899 to your computer and use it in GitHub Desktop.
Save mattbanks/3153899 to your computer and use it in GitHub Desktop.
Create new WP_Query with TextExpander (version 4 required)
<?php
// New query
$%filltext:name=Query Name:default=myquery%_args = array(
'post_type' => '%filltext:name=Post Type:default=post%',
'order' => '%fillpopup:name=popup 7:default=ASC:DESC%',
'orderby' => '%fillpopup:name=popup 9:default=date:ID:rand:title:author:menu_order%',
'post_status' => 'publish',
'posts_per_page' => %filltext:name=Posts Per Page:default=-1%
);
$%filltext:name=Query Name:default=myquery% = new WP_Query( $%filltext:name=Query Name:default=myquery%_args );
if ($%filltext:name=Query Name:default=myquery%->have_posts()) : while ($%filltext:name=Query Name:default=myquery%->have_posts()) : $%filltext:name=Query Name:default=myquery%->the_post(); ?>
<!-- do stuff here -->
<?php endwhile; ?>
<?php else : ?>
<!-- No Results stuff here -->
<?php endif; ?>
<?php wp_reset_postdata(); ?> ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment