Tagged: x
-
AuthorPosts
-
May 29, 2016 at 7:19 am #1015151
LeeParticipantHello,
I thought I would just share this info as I have seen a lot of people trying to solve this and I think I have by combining and altering different posts.
To get the search results to display like woocommerce do the 3 following steps.
#1 Add this code at your child theme functions.php
function searchfilter($query) { if ($query->is_search && !is_admin() ) { $query->set('post_type',array('product')); } return $query; } add_filter('pre_get_posts','searchfilter'); function woocommerce_search_class( $classes ) { if ( is_search() ) { $classes[] = 'woocommerce woocommerce-page'; } return $classes; } add_filter( 'body_class', 'woocommerce_search_class' );#2 Copy and rename file /wp-content/themes/x/woocommerce.php to your child theme /wp-content/themes/x-child/search.php
#3 Add the following customer CSS either in customizer or style.css in your child theme, changing the width for how many columns you want to display. Figure this out by (100% -((#cols – 1) x 4%)) / #cols
.search-results .product { display: block; float: left; margin-right: 4%; margin-bottom: 4%; width: 22%; } .search-results .product:nth-child(4n) { margin-right: 0px !important; }So far I have had no issues with this but if anyone knows any improvements please let me know.
Lee.
May 29, 2016 at 7:25 am #1015161
ChristopherModeratorThanks for sharing.
May 29, 2016 at 8:04 am #1015191
LeeParticipantI do need some help on this though. How can I make it so it displays all product/search results? Thank you.
May 29, 2016 at 8:07 am #1015192
LeeParticipantto add…
I have tried adding
add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 9999;' ), 20 );and also changing Posts Per Page in the customizer but both do nothing to the number of results being displayed.
Lee.
May 29, 2016 at 8:12 am #1015197
ChristianModeratorHey Lee,
Regretfully, this particular customization request is outside the scope of our support as this is not related to an issue with the theme and instead has to do with your customization of it. As such, you will need to investigate this particular issue on your own or seek help from a developer should you not feel comfortable making these changes yourself. If you have any further questions about the theme, we are more than happy to provide you with assistance on these inquiries.
Thank you for your understanding.
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1015151 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
