SearchWP

searchwp\source\attribute\label

Since: 4.0.0

Table of Contents

Customize Source Attribute Label

Parameters

Type Parameter Default Since
String $label Defined label 4.0.0
Array $args
Key Type Value
source String Source name
attribute String Attribute name
4.0.0

Examples

All hooks should be added to your custom SearchWP Customizations Plugin.

Customize Comments Attribute label for Products custom post type

Many Ecommerce plugins (e.g. WooCommerce) use Comments to store Product Reviews. This snippet modifies the label for Comments to be Reviews instead.

<?php
// Customize Comments Attribute label for Products custom post type in SearchWP.
add_filter( 'searchwp\source\attribute\label', function( $label ) {
if ( 'post.product' === $args['source'] && 'comments' === $args['attribute'] ) {
return 'Reviews';
} else {
return $label;
}
}, 20, 2 );

How to use this code