Facebook
From Baby Mockingbird, 2 Years ago, written in PHP.
Embed
Download Paste or View Raw
Hits: 225
  1.    $args = array (
  2.       'post_type' => 'post', // it's default, you can skip it
  3.       'posts_per_page' => '1',
  4.       'order_by' => 'date', // it's also default
  5.       'order' => 'DESC', // it's also default
  6.       'tax_query' => array(
  7.           'relation' => 'AND',
  8.           array(
  9.               'taxonomy' => 'category',
  10.               'field'    => 'slug',
  11.               'terms'    => $category_name,
  12.           ),
  13.           array(
  14.               'taxonomy' => 'post_tag',
  15.               'field'    => 'slug',
  16.               'terms'    => $tag_name,
  17.           ),
  18.       ),
  19.    );
  20.  
  21.    // query is made              
  22.    $query = new WP_Query( $args );