Skip to content

Instantly share code, notes, and snippets.

@micalexander
Last active December 16, 2015 23:09
Show Gist options
  • Select an option

  • Save micalexander/5512372 to your computer and use it in GitHub Desktop.

Select an option

Save micalexander/5512372 to your computer and use it in GitHub Desktop.
wordpress:snippet:query args by first initial of lastname
<?php
$args = array(
'post_type' => 'this-post',
'meta_query' => array(
array(
'key' => 'this-post-last-name',
'value' => array( 'L', chr(ord('L')+1) ),
'orderby' => 'meta_value',
'compare' => 'BETWEEN',
'order' => 'ASC'
),
array(
'key' => 'this-post-last-name',
'value' => chr(ord('L')+1),
'orderby' => 'meta_value',
'compare' => '!='
)
)
);
$query = new WP_Query( $args );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment