0

I want to get listing of multiple taxonomies alphabetically, As the terms are very large in number so will manage using pagination of alphabets, I want to get_terms query for specific alphabets, for example get listing of all terms start with 'B' or 'C'. Please guide how can I achieve this.

Following is getting all terms with B in it, its behaving %B%, but I need B%

    $args = array(
      'orderby'    => 'name', 
      'order'      => 'ASC',
      'name__like' => 'b',
      'number'     => '20', 
    );
1

Maybe try tu use name__like as MySQL LIKE :


$args = array(
      'orderby'    => 'name', 
      'order'      => 'ASC',
      'name__like' => 'b%',
      'number'     => '20', 
    );
  • this doesn't help because internally the SLQ result is t.name LIKE %b%% --- there is no bulit-in function to do that. you sould filter the result of get_terms in a loop to have what you need – mmm Sep 8 '16 at 12:20
  • 1
    My bad. Then you need to loop against the result and remove all terms that doesn't match <pre><code>(substr($term_name, 0,1) === $letter)</code></pre> – Dexter0015 Sep 8 '16 at 12:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.