Dragon主题购买
已解答
公开

你好,请问如何让在线问答插件 DW Question & Answer 支持搜索文章,而不只是搜索问题?

1 人关注这个问题

    1 答案

    公开

    搜索文章就用 WP 的默认文章搜索就好。
    如果是想让 WP 默认的搜索结果中出现问答中心的结果的话也能办到,将下面代码加入 functions.php 中就 OK 了:

    /* 搜索结果设定文章类型为 文章和问答
    /* --------------------- */
    function lxtx_search_filter_page($query) {
    if ($query->is_search) {
    $query->set( 'post_type', array('post', 'dwqa-question') );
    }
    return $query;
    }
    add_filter('pre_get_posts','lxtx_search_filter_page');

     
     

    #1
    1. 好的,谢谢!我试了下现在版本已经默认可以搜索到问答中心的结果了。

    来提交答案

    扫一扫二维码分享
    ×
    We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies. Learn more