Skip to content

Instantly share code, notes, and snippets.

@rayflores
Created December 30, 2014 22:58
Show Gist options
  • Save rayflores/04d5d22f263b395ea68b to your computer and use it in GitHub Desktop.
Save rayflores/04d5d22f263b395ea68b to your computer and use it in GitHub Desktop.
I wanted to show posts from limited deals plugin. Order it by the deal with the most time to expiration, and then ensure that the post contained a limited deal (via checkbox), and show the latest post from there... here is what I ended up with :)
<?php
$args = array(
'post_type' => 'product',
'meta_key' => '_limited_dates_to',
'orderby' => 'meta_value',
'order' => 'DESC',
'meta_query' => array(
array(
'key' => '_limited',
'value' => 'yes',
'compare' => '=',
),
),
'posts_per_page' => 1
);
$limited_query = new WP_Query( $args );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment