Skip to content

Instantly share code, notes, and snippets.

@jchristopher
Created January 22, 2014 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jchristopher/8559060 to your computer and use it in GitHub Desktop.
Save jchristopher/8559060 to your computer and use it in GitHub Desktop.
Related to https://gist.github.com/jchristopher/8558947 — once you have told SearchWP to consider arbitrary meta, you will need to give the meta keys you used a weight in the SearchWP settings. To ensure those keys show up in the Custom Field dropdown on the SearchWP settings page, we can use the searchwp_custom_field_keys filter
<?php
function my_searchwp_author_meta_keys( $keys )
{
// the keys we used to store author meta (see https://gist.github.com/jchristopher/8558947 for more info)
$my_custom_author_meta_keys = array(
'my_author_meta_nicename',
'my_author_meta_display_name',
'my_author_meta_nickname',
'my_author_meta_first_name',
'my_author_meta_last_name',
'my_author_meta_bio'
);
// merge my custom meta keys with the existing keys
$keys = array_merge( $keys, $my_custom_author_meta_keys );
// make sure there aren't any duplicates
$keys = array_unique( $keys );
return $keys;
}
add_filter( 'searchwp_custom_field_keys', 'my_searchwp_author_meta_keys', 10, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment