Note: You are viewing the documentation for Version 4View Version 3 Docs

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

Fix keyword search on your site. No coding required!

Now you can utilize all of the content that's gone unrecognized by native WordPress keyword search instantly with SearchWP

Get SearchWP