Title: Private custom fields
Last modified: July 5, 2017

---

# Private custom fields

 *  Resolved [webmestreglenat](https://wordpress.org/support/users/webmestreglenat/)
 * (@webmestreglenat)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/private-custom-fields/)
 * I use private custom fields. I want to index them in the administration but not
   on the public site. How to do ?

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/private-custom-fields/#post-9293241)
 * It’s possible, but it requires Relevanssi Premium. The free version doesn’t know,
   which custom field matches the search term, it just knows some custom field did.
   With the free version, you can make all custom fields private or public, not 
   some of them. With Premium, you can have more fine-tuned control.
 * The actual code is fairly simple:
 *     ```
       add_filter('relevanssi_match', 'rlv_private_custom_fields');
       function rlv_private_custom_fields($match) {
       	global $wp_query;
       	$private_custom_fields = array("total_sidebar_layout");
       	if (!$wp_query->is_admin) {
       		$customfield_detail_array = unserialize($match->customfield_detail);
       		if (is_array($customfield_detail_array)) {
       			foreach (array_keys($customfield_detail_array) as $field) {
       				if (in_array($field, $private_custom_fields)) {
       					$match->weight = 0;
       					break;
       				}
       			}
       		}
       	}
       	return $match;
       }
       ```
   
 * Just list the names of the private custom fields in the array, and if the search
   is a frontend search and the custom field matches one of those, the post weight
   is set to zero.
 *  Thread Starter [webmestreglenat](https://wordpress.org/support/users/webmestreglenat/)
 * (@webmestreglenat)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/private-custom-fields/#post-9293854)
 * Perfect, thank you for your quick return

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Private custom fields’ is closed to new replies.

 * ![](https://ps.w.org/relevanssi/assets/icon-256x256.png?rev=3529670)
 * [Relevanssi - A Better Search](https://wordpress.org/plugins/relevanssi/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/relevanssi/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/relevanssi/)
 * [Active Topics](https://wordpress.org/support/plugin/relevanssi/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/relevanssi/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/relevanssi/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [webmestreglenat](https://wordpress.org/support/users/webmestreglenat/)
 * Last activity: [8 years, 10 months ago](https://wordpress.org/support/topic/private-custom-fields/#post-9293854)
 * Status: resolved