将自定义字段添加到搜索和结果中

时间:2012-09-06 18:51:10

标签: wordpress

我正在使用插件“WP Search Suggest”在搜索字段中建议。 现在,该插件运行良好,但它只建议和搜索标题。

我看了插件,发现了这个:

    $query_args = apply_filters(
        'wpss_search_query_args',
        array(
            's'             =>  $s,
            'post_status'   =>  'publish',
            'post_type'     =>  'movie',
        ),
        $s
    );

    $query = new WP_Query( $query_args );

    if ( $query->posts ) {

        foreach ( $query->posts as $post ) {
            $results[] = $post->post_title;
        }

        $results = apply_filters(
            'wpss_search_results',
            $results,
            $query
        );

        echo join( $results, "\n" );

    }

我试图通过添加以下内容来添加对自定义字段的支持:

'meta_key'      =>  'somthing',
'meta_value'        =>  '$s'

但是我没有工作,并没有找到一种方法来“回显”结果,因为'$ query-> posts'数组不包含元键或值......

0 个答案:

没有答案