duanbozhong9689 2016-09-14 18:27
浏览 46

如何在搜索结果中显示特定类别

How can I display search results in a specific category? e.g When searching for word 'articles', search results should display category 'Articles'.

  • 写回答

1条回答 默认 最新

  • doucaishi0077 2016-09-15 06:14
    关注

    It should be possible to create this feature with the post_search wordpress filter.

    See: https://codex.wordpress.org/Plugin_API/Filter_Reference/posts_search

    The post_search filter is executed before the category check so you should be able to set the category in the query based on the search terms. Beyond that it is a matter of adjusting your template(s) to display the category used by the query.

    评论

报告相同问题?