Skip to content

Instantly share code, notes, and snippets.

@astockwell
Created May 2, 2013 22:59
Show Gist options
  • Save astockwell/5506110 to your computer and use it in GitHub Desktop.
Save astockwell/5506110 to your computer and use it in GitHub Desktop.
WP_Query by meta_value first letter
<?php
$args = array(
'post_type' => 'faculty',
'meta_query' => array(
// 'relation' => 'AND',
// array(
// 'key' => 'online-extra-type',
// 'value' => 'Your Space',
// 'compare' => '='
// ),
array(
'key' => 'faculty-last-name',
'value' => array( 'L', chr(ord('L')+1) ),
'orderby' => 'meta_value',
'compare' => 'BETWEEN',
'order' => 'ASC'
),
array(
'key' => 'faculty-last-name',
'value' => chr(ord('L')+1),
'orderby' => 'meta_value',
'compare' => '!='
)
)
);
$devquery = new WP_Query( $args );
print_r($devquery);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment