First Question’s Answer:
For filtering based on your terms first letter you need to filter the query, which you can do with the terms_clauses
hook. By putting the below code block in your theme’s functions.php
you can do that-
function the_dramatist_filter_term_clauses( $clauses ) {
remove_filter('term_clauses','the_dramatist_filter_term_clauses');
$pattern = '|(name LIKE )\'%(.+%)\'|';
$clauses['where'] = preg_replace($pattern,'$1 \'$2\'',$clauses['where']);
return $clauses;
}
add_filter('terms_clauses','the_dramatist_filter_term_clauses');
Second Question’s Answer:
I don’t think you need to create separate 27 pages for every letter. Rather you can use $_GET
variable to do that for you. By using this $_GET
variable you can pass the letter as parameter that you need to be and catch this to $name__like = isset($_GET['your_get_variable name']) ? $_GET['your_get_variable name'] : '';
. Then pass it to $args
array. The array will look like below-
$name__like = isset($_GET['your_get_variable name']) ? $_GET['your_get_variable name'] : '';
$args = array(
'name__like' => $name__like,
'order' => 'ASC',
'hide_empty' => 0 // Put 0 If you need to show the empty terms otherwise 1
);
Hope that helps.