WordPress - 主页中的自定义产品搜索选项

时间:2018-03-13 18:52:25

标签: php wordpress woocommerce content-management-system

我是一个WordPress网站,我正在尝试在网站的首页以及标题部分添加自定义搜索选项。遗憾的是,我无法从网站的信息中心看到任何选项,并决定按照以下链接创建自定义链接:

Tutorial Link - Custom Search

这是我和教程一样尝试的代码:

add_action('tickercontainer','add_search_to_footer'); //Guessinghere I've to declare the div class

function add_search_to_footer() {
get_search_form();
}

function SearchFilter($query) {
if ( !is_admin() && $query->is_search ) {
$query->set('post_type', 'post'); //OR USE 'PRODUCT'
}
return $query;
}

add_filter('pre_get_posts','SearchFilter');

function storefront_search_form_modify( $html ) {
    return str_replace( array('Search …','Search'), array('WooCommerce Hooks, Storefront Theme, Google AdWords...','Search Article'), $html );
}

add_filter( 'get_search_form', 'storefront_search_form_modify' );

function new_nav_menu_items($items) {
    $searchicon = '<li class="search"><a href="#colophon"><i class="fa fa-search" aria-hidden="true"></i></a></li>';
    $items = $items . $searchicon;
    return $items;
}

add_filter( 'wp_nav_menu_additional-resources_items', 'new_nav_menu_items' );

虽然我不确定我在这里缺少什么,并希望以适当的方式实施一些想法。

注意:现在,在包含上述代码后,我无法在网站上看到搜索选项。

0 个答案:

没有答案
相关问题