[英]Search box in menubar wordpress using Customizr Theme woocommerce
大家好,我正在尝试在菜单栏中放置一个搜索框,但我能够做到这一点,但是我该如何使用woocommerce搜索产品呢?
这是我当前在function.php中的代码:
add_filter( 'wp_nav_menu_items','add_search_box', 10, 2 );
function add_search_box( $items, $args ) {
$items .= '<li>' . get_search_form( false ) . '</li>';
return $items;
}
我想将Woocommerce_product_search放在我的MENUBAR中,任何人都可以帮助我。
对英语的抱歉真的不好。
在您的Functions.php中注册一个侧边栏,然后将侧边栏添加到您要显示搜索框的容器中。 然后将Woocommerce搜索小部件添加到Wordpress Admin界面内的此侧栏中。
将此添加到Functions.php:
register_sidebar(array(
'id' => 'search-widget',
'name' => __('Search Widget'),
'description' => __('Drag search widget to this container'),
'before_widget' => '<article id="%1$s" class="widget %2$s">',
'after_widget' => '</article>',
'before_title' => '<h6>',
'after_title' => '</h6>'
));
}
将此添加到您的Header.php或包含搜索框所需代码的任何文件中:
<?php dynamic_sidebar("search-widget"); ?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.