-
Search Results
-
Hello, I am wondering if it’s possible to style the select box on the filter to match my clients specifications on their blog wordpress site. Here is a screenshot of what they’re looking for – http://puu.sh/F53Qy/fc5a116035.png. Any and all help would be greatly appreciated.
Topic: Work with native search form
So… I am trying to get a basic search field (in a header) to work with a sidebar filter to end up in woocommerce styled pages (the sidebar is not everywhere). Problem one is S&F says I can’t have two different forms that two different forms that use the Woocommerce Shop Display Results option — why not?
In any case, I pretty much got a native search form to work in the header and direct to a woocommerce archive page by redirecting the search to my catalog page which has the sidebar filter. However, it doesn’t work with the sidebar filter. So, I can search, but all the filters ignore the search term.
How can I get the filters to honor (and remember) the query results that the user entered from a WP search? Or how can I have two different forms end up in the same place?
The only thing I can think of would be to add a search to the sidebar and then pre-populate the field with a get_search_query(). But that seems overly hacky to me.
Hi,
I have these taxonomies:
– Product
– Merchant
– Merchant offerI created a custom post template to make it possible to view all merchant offers for a product, with the possibility to filter on both merchant meta fields (review, payment methods..) as on merchant offer meta fields (price, delivery time..)
Now I see that the S&F Pro plugin shows filter options for every existing post instead of the current viewed product. When you see my code below (this is my very first php-code, so when it is looking strange, that’s why), do you have a hint how to show only filter options for the current viewed product?<?php /* * Template Name: Product * Template Post Type: post, page, product, item */ get_header(); ?> <?php $link = get_post_custom_values("link") [0]; $color = get_post_custom_values("kleur") [0]; //echo get_post_custom_values("product_group")[0]; ?> <div id="content" class="site-content"> <section id="primary" class="content-area"> <main id="main" class="site-main"> <article id="post-2" class="post-2 page type-page status-publish hentry entry"> <div class = "pdp-full-top"> <div class = "pdp-top-container entry-header"> <h1 class = "pdp-title"> <?php $brand = get_post_custom_values("brand") [0]; $line = get_post_custom_values("line") [0]; $type = get_post_custom_values("type") [0]; $variant = get_post_custom_values("variant_value") [0]; echo $brand . " " . $line . " " . $type . " " . $variant; ?> </h1> <div class = "pdp-image-container"><div class = "pdp-image-helper"></div><?php the_post_thumbnail(); ?> </div> <div class = "pdp-top-info-container"> <h2 class = "pdp-sub-title"> <?php $product_group = get_terms(array( 'taxonomy' => 'productgroep', 'hide_empty' => false, )) [0]->name; echo $product_group . ", " . $variant; ?> </h2> <h5 class = "pdp-choise-criteria">Keuzecriteria</h5> <div class = "pdp-price">Prijs vanaf ... </div> </div> </div> </div> <div class = "pdp-lister-container entry-content"> <?php //Filter area ?> <div class = "pdp-filter-container"> <?php echo do_shortcode('[searchandfilter id="165176"]'); ?> <?php echo do_shortcode('[searchandfilter id="153395"]'); ?> </div> <div class = "pdp-shopping-list-container"> <?php //Get all merchants $ean = get_field("ean"); $args_merchants = array( 'post_type' => 'merchant_offer', 'tax_query' => array( array( 'taxonomy' => 'ean', 'field' => 'slug', 'terms' => $ean, 'compare' => '=' ) , ) ); $offers = new WP_Query($args_merchants); $all_merchants = []; while ($offers->have_posts()): $offers->the_post(); $get_merchant = get_post_meta(get_the_ID() , 'merchant_id') [0]; array_push($all_merchants, $get_merchant); endwhile; //Get filtered merchants wp_reset_postdata(); wp_reset_query(); $args_offers = array( 'post_type' => 'merchants', 'search_filter_id' => 153395, 'tax_query' => array( 'relation' => 'OR', array( 'taxonomy' => 'merchant_id', 'field' => 'slug', 'terms' => $all_merchants, 'operator' => 'IN', ) , ) ); $query2 = new WP_Query($args_offers); $filtered_merchants = []; $post_id_by_merchant = []; while ($query2->have_posts()): $query2->the_post(); $get_filtered_merchant = get_post_meta(get_the_ID() , 'merchant_id') [0]; array_push($filtered_merchants, $get_filtered_merchant); $post_id_by_merchant[$get_filtered_merchant] = get_the_ID(); endwhile; //Get filtered offers by filtered merchants wp_reset_postdata(); wp_reset_query(); $args_filtered_offers = array( 'post_type' => 'merchant_offer', //add filter id somewhere here! 'search_filter_id' => 165176, 'tax_query' => array( 'relation' => 'AND', array( 'taxonomy' => 'ean', 'field' => 'slug', 'terms' => $ean, ) , array( 'taxonomy' => 'merchant_id', 'field' => 'slug', 'terms' => $filtered_merchants, ) , ) , ); $query3 = new WP_Query($args_filtered_offers); //Build shopping list ?> <div class = "pdp-shopping-list"> <div class = "row header"> <div class = "item"></div> <div class = "item">Winkel</div> <div class = "item">Reviews</div> <div class = "item">Basisprijs</div> <div class = "item">Totaalprijs</div> <div class = "item"></div> </div> <?php while ($query3->have_posts()): $query3->the_post(); setlocale(LC_MONETARY, 'nl_NL'); $current_merchant_id = $post->merchant_id; $stars = floatval(get_post_meta($post_id_by_merchant[$current_merchant_id], 'reviewsterren', true)); $review_amount = get_post_meta($post_id_by_merchant[$current_merchant_id], 'aantal_reviews', true); ?> <div class = "row"> <div class = "item logo"><?php echo get_the_post_thumbnail($post_id_by_merchant[$current_merchant_id]); ?></div> <div class = "name"><?php echo get_post_meta($post_id_by_merchant[$current_merchant_id], 'name', true) ?></div> <div class = "review-container"><div class="stars" style="--rating: <?php echo $stars ?>;" aria-label="Rating of this product is <?php echo $stars ?> out of 5."></div><div class = "reviews"><?php echo $review_amount . " reviews" ?></div></div> <div class = "item price-actual"><?php echo money_format("€%.2n", $post->price_actual); ?></div> <div class = "item price-total"><?php echo money_format("€%.2n", $post->total_price); ?></div> <div class = "item view"><button class = "button"><a href="<?php echo $post->link; ?>" target="blank">Bekijken</a></button> </div> </div> <?php endwhile; ?> </div> <?php wp_reset_postdata(); wp_reset_query(); ?> </div> </div> </main> </section> </div>
Thanks again in advance.
Best regards,
Roeland van Oostenbrugge