2016-11-09 2 views

답변

2

검색을 기반으로하는 필드를 확실히 사용자 지정할 수 있습니다.

당신이 Algolia 당신 만 attributesToIndex 설정을 변경하여 게시물 제목 필드에 검색 할 것을 알려 모두의

첫째 :

/** 
* @param array $settings 
* 
* @return array 
*/ 
function custom_posts_index_settings(array $settings) { 
    $settings['attributesToIndex'] = array('unordered(post_title)'); 

    return $settings; 
} 

add_filter('algolia_posts_index_settings', 'custom_posts_index_settings'); 
add_filter('algolia_searchable_posts_index_settings', 'custom_posts_index_settings'); 

그런 다음 처음으로 자동 완성의 제안 템플릿을 사용자 정의 할 필요를 이 가이드에 설명 된 같은 테마의 폴더에 autocomplete.php 파일을 이동 : https://community.algolia.com/wordpress/customize-autocomplete.html

은 기본적으로 당신이 보이는 부분을 제거합니다 일이 같은 :

<# 
      var attributes = ['content', 'title6', 'title5', 'title4', 'title3', 'title2', 'title1']; 
      var attribute_name; 
      var relevant_content = ''; 
      for (var index in attributes) { 
      attribute_name = attributes[ index ]; 
      if (data._highlightResult[ attribute_name ].matchedWords.length > 0) { 
      relevant_content = data._snippetResult[ attribute_name ].value; 
      break; 
      } else if(data._snippetResult[ attribute_name ].value !== '') { 
      relevant_content = data._snippetResult[ attribute_name ].value; 
      } 
      } 
      #> 
+0

이 전체 부분을 제거하면 결과가 자동 완성되지 않습니다. 단지 'content'속성을 제거해야한다는 의미입니까? –

+0

최종 인스턴스를 볼 수 있도록 라이브 인스턴스를 공유 하시겠습니까? – rayrutjes