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.0.3

searchwp_get_custom_fields

View Parameters »

When SearchWP indexes a post object, it retrieves all of the metadata for that object. If you would like to manipulate that Custom Field data in any way, you can use this hook like so, by adding something like the following to your theme’s functions.php:

<?php
function my_searchwp_get_custom_fields( $custom_fields, $post_id ) {
// manipulate the array of Custom Fields in any way you'd like
return $custom_fields;
}
add_filter( 'searchwp_get_custom_fields', 'my_searchwp_get_custom_fields', 10, 2 );
view raw gistfile1.php hosted with ❤ by GitHub

Parameters

Parameter Type Description
$custom_fields Array

The postmeta (Custom Fields) for the post being indexed

$post_id Integer

The ID of the post being 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