Available since: 2.3
searchwp_indexer_tag_attributes
View Parameters »Note: Use of this hook will require a manual reindex
By default SearchWP will parse any HTML it finds in your content in an attempt to extract what it considers useful information that should be included in the index. The defaultĀ attributes for the default tags that are processed include:
Tag | Indexed attributes |
---|---|
a |
title |
img |
alt , src , longdesc , title |
input |
placeholder , value |
If you would like to change what tags and attributes SearchWP considers to be useful, add something like the following to your theme’s functions.php
:
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 | |
function my_searchwp_indexer_tag_attributes( $tags ) { | |
// do not index img tags at all | |
if ( isset( $tags['img'] ) ) { | |
unset( $tags['img'] ); | |
} | |
// index our custom Reference data attribute on <article>s | |
$tags['article'] = array( 'data-reference' ); | |
return $tags; | |
} | |
add_filter( 'searchwp_indexer_tag_attributes', 'my_searchwp_indexer_tag_attributes' ); |
Parameters
Parameter | Type | Description |
---|---|---|
$tags |
Array |
Associative array keys with HTML tags considered valuable, each value representing the attributes that should be indexed |