2014-02-08 1 views
2

에 의해 시작이 게시물을 받기 카테고리 이름은 예를 들어 용어로 시작합니다.내가 예를 들어 WP_Query 클래스를 사용하는 경우 카테고리 이름이 용어

$query = new WP_Query('category_name=s%'); 

나는 내 질문에 대해 설명하기를 바란다.

<?php 

/** 
* @ $taxonomy = the taxonomy name 
* @ $search = the string you are searching 
* @ return array of term names 
*/ 
function getDesiredTerms($taxonomy, $search) { 

    $result = get_terms(
     $taxonomy, 
     array(
      'hide_empty' => false, // get them all   
      'fields'  => 'names', // get only the term names 
      'name__like' => $search // Note: This was changed in WordPress 3.7, when previously name__like matched terms that begin with the string. 
      ) 
     ); 
    return $result; 

} 

당신이 사용하고있는 워드 프레스 버전에 유의하십시오처럼 감사

답변