2016-11-26 3 views
0

私のカスタムポストの検索クエリを書いています。私はこれにWP_Queryの検索パラメータを使用していますが、 'post_title' & 'post_content'の両方を検索する必要がありますが、 'post_title'だけを検索していて、 'post_content'は検索していません。以下の私のコードです:WP_Queryの 's' => 'キーワード'は 'post_title'のみを検索し、なぜ 'post_content'を検索しないのですか?

$institute_name = get_user_meta($user_ID, 'inistitute_name', true); 
add_filter('posts_where' , array($this,'posts_where')); 
$paged = (get_query_var('page')) ? get_query_var('page') : 1; 
     $args = array(
      'post_type' => 'mypost', 
      array('s' => $keyword), 
      'meta_query' => array (
       array (
        'key' => 'inistitute_name', 
        'value' => array ($institute_name), 
        'compare' => 'IN' 
       ) 
      ), 
      'posts_per_page' => -1, 
      'paged' => $paged, 
      'post_status' => 'publish', 
      ); 
$the_query = new WP_Query($args); 
remove_filter('posts_where', array($this,'posts_where')); 
echo "<pre>"; 
print_r($the_query); 
echo "</pre>"; 

私はその結果を印刷する場合、私は以下のようなクエリ取得しています:私はそれだけで「POST_TITLE」のため正常に動作しているが、それはない理由を言ったように

SELECT wp_dxwe_posts.* FROM wp_dxwe_posts INNER JOIN wp_dxwe_postmeta ON 
(wp_dxwe_posts.ID = wp_dxwe_postmeta.post_id) WHERE 1=1 AND 
((wp_dxwe_postmeta.meta_key = 'inistitute_name' AND 
CAST(wp_dxwe_postmeta.meta_value AS CHAR) IN ('ITeLearn'))) 
AND wp_dxwe_posts.post_type = 'mypost' AND ((wp_dxwe_posts.post_status = 'publish')) 
AND post_title LIKE '%launch%' GROUP BY wp_dxwe_posts.ID 
ORDER BY wp_dxwe_posts.post_date DESC 

を'post_content'のために働いています。誰でもこのコードの何が間違っているか教えてください。前もって感謝します。

答えて

0

適切な全文索引がないと、全身を検索するには時間がかかりすぎ、大きなサイトではサーバーのパフォーマンスが低下する可能性があります。

+0

えええええええええええええええええええええええええええええええええええええええええええええええええええええええ回答:私は 'post_title'だけが働いていたと言っていたので、他のタイトルを試してみると、それは結果を表示していないのです。もしそうなら、解決策は何ですか? –

関連する問題