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
|
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); |