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

Documentation

View the installation guide, browse the Knowledge Base, find out about SearchWP's many hooks, get support

Available since: 2.9

searchwp_engine_content_type_label

View Parameters »

SearchWP recognizes that native content attributes (e.g. Excerpts, Comments, etc) are sometimes repurposed to better suit their context. For example, WooCommerce uses Comments for Product Reviews. Using this hook you can customize the attribute label to match its intended purpose.

Example: if you’re using Excerpts as Abstracts when writing Posts, add the following to your theme’s functions.php to have SearchWP use “Abstract” instead of “Excerpt” as the label:

<?php
// Customize the 'Excerpt' label for Posts in SearchWP's engine configuration
add_filter( 'searchwp_engine_content_type_label', function( $label, $context ) {
if ( 'post' === $context['post_type'] && 'excerpt' === $context['supports'] ) {
$label = 'Abstract';
}
return $label;
}, 10, 2 );
view raw functions.php hosted with ❤ by GitHub

Parameters

Parameter Type Description
$label String

The label for the content type

$context Array

Contains post_type and supports keys

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