Tagged: search, taxonomies, woocommerce
Hi. I have a site in development that is using custom taxonomies to show product search results in woocommerce. I would like to know how to change the appearance of the search results to show 3 of the taxonomy values. Currently, the only info shown for each product on the product search results page is “Product name” and Product Price”. I would like to show the taxonomy values of ‘square_footage’ ‘number_of_bedrooms’ and ‘number_of_bathrooms’. I would also be okay with simply showing all the custom taxonomies. The link to the website search is below. I appreciate any help you can provide.
Hey alexbonesteel,
Thank you for using Enfold.
You will have to use WooCommerce hooks to add more info to the product container. Something like this:
add_action( 'woocommerce_before_shop_loop_item_title', 'avia_shop_overview_extra_header_div', 20);
function avia_shop_overview_extra_header_div()
{
echo "
<div class='inner_product_header'>
<div class='avia-arrow'></div>
";
echo "
<div class='inner_product_header_table'>";
echo "
<div class='inner_product_header_cell'>";
}
add_action( 'woocommerce_after_shop_loop_item_title', 'avia_close_div', 1000);
add_action( 'woocommerce_after_shop_loop_item_title', 'avia_close_div', 1001);
add_action( 'woocommerce_after_shop_loop_item_title', 'avia_close_div', 1002);
That particular hook wraps the title inside 3 divs or containers and then close it. If you want to display terms from a certain taxonomy, please look into the “get_the_terms” function.
// https://developer.wordpress.org/reference/functions/get_the_terms/
Best regards,
Ismael