php WooCommerce产品搜索过滤器标记

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php WooCommerce产品搜索过滤器标记相关的知识,希望对你有一定的参考价值。


/* Woo Search */

.widget_product_search {
	overflow: auto;
}

.widget_product_search #searchform {
	float: left;
}

.widget_product_search input[type="text"],
.widget_product_search button[type="submit"] {
	border-radius: 0;
	padding: 6px;
}
.widget_product_search input[type="text"] {
	width: 200px;
	float: right;
	padding: 14px;
}

.widget_product_search button[type="submit"] {
	float: right;
}

.widget_product_search button[type="submit"]:hover,
.widget_product_search button[type="submit"]:focus {
	background: #f9ba00;
	border: #fff 1px solid;
	color: #000;
}
<?php

add_filter( 'get_product_search_form' , 'me_custom_product_searchform' );

/**
 * Filter WooCommerce  Search Field
 *
 */
function me_custom_product_searchform( $form ) {
	
        $form = '<form role="search" method="get" id="searchform" action="' . esc_url( home_url( '/'  ) ) . '">
                        <div>
                                <label class="screen-reader-text" for="s">' . __( 'Search for:', 'woocommerce' ) . '</label>
                                <input type="text" value="' . get_search_query() . '" name="s" id="s" placeholder="' . __( 'My Search form', 'woocommerce' ) . '" />
                                <input type="submit" id="searchsubmit" value="'. esc_attr__( 'Search', 'woocommerce' ) .'" />
                                <input type="hidden" name="post_type" value="product" />
                        </div>
                </form>';

return $form;


}
<?php


add_filter( 'get_product_search_form' , 'me_custom_product_searchform' );

/**
 * Filter WooCommerce  Search Field
 *
 */
function me_custom_product_searchform( $form ) {
	
	$form = '<form role="search" method="get" id="searchform" action="' . esc_url( home_url( '/'  ) ) . '">
                        <div>
                                <label class="screen-reader-text" for="s">' . __( 'Search for:', 'woocommerce' ) . '</label>
                                <button type="submit" id="searchsubmit" />
                                        <span class="icon"><i class="fa fa-search"></i></span>   
                                </button>  
                                <input type="text" value="' . get_search_query() . '" name="s" id="s" placeholder="' . __( 'Search products...', 'woocommerce' ) . '" />                           
                                 <input type="hidden" name="post_type" value="product" />
                        </div>
                </form>';
return $form;


}

以上是关于php WooCommerce产品搜索过滤器标记的主要内容,如果未能解决你的问题,请参考以下文章

php WooCommerce:过滤产品类别列表

PHP中的问题过滤woocommerce产品

WooCommerce 产品类别计数

php 按类别筛选搜索 - woocommerce产品

php WooCommerce产品搜索

php WooCommerce产品搜索