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

Documentation

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

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:

<?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' );
view raw gistfile1.php hosted with ❤ by GitHub

Parameters

Parameter Type Description
$tags Array

Associative array keys with HTML tags considered valuable, each value representing the attributes that should be indexed

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