mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-29 11:32:21 +08:00
https://advanced-woo-search.com/guide/how-to-add-custom-data-inside-search-results/#showing-product-custom-taxonomies
12 lines
564 B
Text
12 lines
564 B
Text
add_filter( 'aws_excerpt_search_result', 'my_aws_excerpt_search_result', 10, 2 );
|
|
function my_aws_excerpt_search_result( $excerpt, $post_id ) {
|
|
$brands = get_the_terms( $post_id, 'product_brand' );
|
|
$all_brands = array();
|
|
if ( ! is_wp_error( $brands ) && ! empty( $brands ) ) {
|
|
foreach ( $brands as $brand ) {
|
|
$all_brands[] = $brand->name;
|
|
}
|
|
$excerpt = $excerpt . '<br>' . '<span style="margin-top: 3px;display: block;color: #330ced;">Brands: ' . implode( ',', $all_brands ) . '</span>';
|
|
}
|
|
return $excerpt;
|
|
}
|