I need some help with this, The goal is to filter the post titles by letters. If I click "E", It should only show all post titles that starts with "E".
I am wonder if the 'key' for post title is actually 'post_title' I can't seem to get any results. I have attached an image to refer to.
$letter = $_POST['letter'];
$args = array(
'post_type' => 'directory',
'posts_per_page' => -1,
'order' => 'asc',
'meta_key'=> 'listing',
);
if(!empty($letter)){
$args['meta_query'] = array( // tax_query is an array of arrays;
array(
'key' => 'post_title',
'value' => $letter."%",
'compare' => 'LIKE',
)
);
}
$query = new WP_Query( $args );