This Documentation is for SearchWP Version 3

Available since: 3.1


View Parameters »

Note: Use of this hook will require a manual reindex

By default when using SearchWP’s Extra Metadata feature the data is stored only in SearchWP’s index so as to keep database utilization to a minimum.

If you would like SearchWP to also store your Extra Metadata in your postmeta table you can add this to your theme’s functions.php:

add_filter( 'searchwp_persist_extra_metadata', '__return_true' );
view raw functions.php hosted with ❤ by GitHub

With that hook in place SearchWP will index your Extra Metadata as is the default behavior, but it will also add your Extra Metadata to your postmeta table as well. These postmeta records will only be referenced internally by SearchWP.

Some notes:

  • In addition to the SearchWP index, your Extra Metadata will be stored in your postmeta database table as well
  • When using Extra Metadata in your engine(s) you will still need to add your Extra Metadata keys as per the docs (this is important!)
  • Persisted Extra Metadata will not be indexed twice, it will remain as Extra Metadata as far as the SearchWP index is concerned
  • Your Custom Field dropdown keys will exclude these internal storage keys so they won’t be directly available
  • When evaluating quoted searches, the Extra Metadata keys that have been added to your engine will be utilized to perform matches against the persisted metadata that now appears in your postmeta table

What is the use case?

The original implementation of Extra Metadata was designed to allow you to add valuable search data to SearchWP’s index without cluttering up your postmeta table. SearchWP 3.1 introduced the ability to perform quoted/phrase/sentence searches, which introduced a problem:

Extra Metadata will not work with quoted searches because Extra Metadata exists only as tokenized data in SearchWP’s index.

Persisting Extra Metadata is primarily a workaround for this limitation, as quoted searches are supported when Extra Metadata is persisted.


Parameter Type Description
$enabled Boolean

Whether Extra Metadata should be persisted