[wordpress插件] Bang Faceted Search邦多面搜索

wordpress 插件 文章 2020-02-29 01:50 476 0 全屏看文

AI助手支持GPT4.0

评分
0
描述

A faceted search is one that allows you to drill down by various fields:

多面搜索是一种可让您按各个字段进行深入研究的搜索:

price, size, colour, shipping location etc.

价格,尺寸,颜色,运输地点等。

It complements a free text search rather than replaces it.

它是对自由文本搜索的补充而不是替代。

Using this plugin, you can create a faceted search interface for your pages and posts,

使用此插件,您可以为页面和帖子创建多面搜索界面,

or any other custom post type.

或任何其他自定义帖子类型。

You can add “facets” for:

您可以为以下项添加“方面”:

    • Taxonomies
    • 分类法

    • Custom fields
    • 自定义字段

    • Dates (day, week, month or year)
    • 日期(日,周,月或年)

    • Author
    • 作者

    These facets are widgets that can be easily changed in the admin interface.

    这些方面是可以在管理界面中轻松更改的小部件。

安装步骤

    1. Upload the bang-faceted-search directory to your /wp-content/plugins/ directory
    2. bang-faceted-search 目录上传到您的 / wp-content / plugins / 目录

    3. Activate the plugin through the ‘Plugins’ menu in WordPress
    4. 通过WordPress中的“插件”菜单激活插件

    5. Create a template search.php in your theme
    6. 在主题中创建模板 search.php

    Creating a search template

    创建搜索模板

    You need to create a search template in your theme called search.php.

    您需要在主题中创建一个名为 search.php 的搜索模板。

    This template will be used whenever the user searches your site.

    每当用户搜索您的网站时,都会使用此模板。

    Add this code to your functions.php to create a search-specific sidebar:

    将此代码添加到您的 functions.php 中,以创建特定于搜索的侧边栏:

    register_sidebar(array(  

      register_sidebar(array(  

    'name' => 'Search',  

    '名称'=>'搜索',  

    'id' => 'search'

    'id'=>'搜索'

    ));

    ));

    Your search template should include that sidebar:

    您的搜索模板应包含该侧边栏:

      <?php dynamic_sidebar('search'); 

    ?>

    ?>

    Then in the admin interface, drag Facet widgets into that sidebar to add, customise

    然后在管理界面中,将Facet小部件拖动到该侧栏中以添加,自定义

    and re-order the search widgets for your site.

    并重新排序您网站的搜索窗口小部件。

    Customising the faceted search

    自定义多面搜索

    Your site can have more than the default search page, and you can use the

    您的网站可以包含多个默认搜索页面,并且您可以使用

    faceted search plugin to search custom post types.

    多面搜索插件可搜索自定义帖子类型。

    To make a custom search, create a page with a custom template in your theme.

    要进行自定义搜索,请在主题中创建一个带有自定义模板的页面。

    For example, if you have a page called /products, then create a template

    例如,如果您有一个名为 / products 的页面,则创建一个模板

    in your theme called products.php.

    在名为 products.php 的主题中。

    Near the start of this template, call this code:

    在此模板的开头附近,调用以下代码:

    $faceted_search = bang_faceted_search(null, array(  

      $ faceted_search = bang_faceted_search(null,array(  

    'force' => array(    

    '力'=>数组(    

    'post_type' => 'product'  

    'post_type'=>'产品'  

    )

    ));

    ));

    Later on, display the results with something like:

    稍后,显示类似以下内容的结果:

    if ($faceted_search->has_posts()) {  

      if($ faceted_search-> has_posts()){  

    echo "

    Search results

    ";  

    回显“

    搜索结果”;  

    $faceted_search->write_feedback();  

    $ faceted_search-> write_feedback();  

    $posts = $faceted_search->get_posts();  

    $ posts = $ faceted_search-> get_posts();  

    global $post;  

    全球$ post;  

    $original_post = $post;  

    $ original_post = $ post;  

    foreach ($posts as $post) {    

    foreach(将$ posts作为$ post){    

    setup_postdata($post);    

    setup_postdata($ post);    

    // ... write the post ...  

    // ...写帖子...  

    }  

    }  

    $post = $original_post;  

    $ post = $ original_post;  

    setup_postdata($post);  

    setup_postdata($ post);  

    echo $faceted_search->paginate();

    echo $ faceted_search-> paginate();

    }

    }

下载地址
https://downloads.wordpress.org/plugin/bang-faceted-search.zip
-EOF-

AI助手支持GPT4.0