Title: Exclude Specific Custom Fields
Last modified: August 24, 2016

---

# Exclude Specific Custom Fields

 *  [Mallander](https://wordpress.org/support/users/mallander/)
 * (@mallander)
 * [11 years ago](https://wordpress.org/support/topic/exclude-specific-custom-fields/)
 * Hi There,
 * Is there a way I can exclude certain custom fields from being searched?
 * There are certain custom fields (image fields) that I don’t want to be searched
   as it’s bringing up some incorrect results.
 * Thanks,
 * Mallander
 * [https://wordpress.org/plugins/search-everything/](https://wordpress.org/plugins/search-everything/)

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

 *  [Nick Ciske](https://wordpress.org/support/users/nickciske/)
 * (@nickciske)
 * [11 years ago](https://wordpress.org/support/topic/exclude-specific-custom-fields/#post-6176199)
 * Looks like you could tack that on using the `posts_where` filter… maybe.
 * Would take some rooting around in the code to get the table prefix and format
   right (there are category exclusions you could model your code after).
 *  [jamesbo](https://wordpress.org/support/users/jayjayph/)
 * (@jayjayph)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/exclude-specific-custom-fields/#post-6176440)
 * Really great plugin out-of-the-box but as Mallander asked, how can we exclude
   specific custom fields not to be searcheable?
 * An example code for the post_where hook will be appreciated.
 *  [ditler](https://wordpress.org/support/users/ditler/)
 * (@ditler)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/exclude-specific-custom-fields/#post-6176442)
 * I have patched lines 569ff as follows:
 *     ```
       .
       		$search .= "{$searchand}( (m.meta_value LIKE '{$n}{$term}{$n}') AND NOT (m.meta_key LIKE 'content%') )";
       	} else {
       		$search .= "{$searchand}( (meta_value LIKE '{$n}{$term}{$n}') AND NOT (meta_key LIKE 'content%') )";
       	}
       	$searchand = ' AND ';
       }
       $sentence_term = esc_sql( $s );
       if ( count( $search_terms ) > 1 && $search_terms[0] != $sentence_term ) {
       	if ( $this->wp_ver23 ) {
       		$search = "($search) OR (m.meta_value LIKE '{$n}{$sentence_term}{$n}') AND NOT (m.meta_key LIKE 'content%') )";
       	} else {
       		$search = "($search) OR ( (meta_value LIKE '{$n}{$sentence_term}{$n}') AND NOT (meta_key LIKE 'content%') ) ";
       ```
   
 * The AND NOT parts are where the exclusion comes into play.
 * I would also be glad if there is a patch, though.

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

The topic ‘Exclude Specific Custom Fields’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/search-everything_242529.svg)
 * [Search Everything](https://wordpress.org/plugins/search-everything/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/search-everything/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/search-everything/)
 * [Active Topics](https://wordpress.org/support/plugin/search-everything/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/search-everything/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/search-everything/reviews/)

## Tags

 * [custom fields](https://wordpress.org/support/topic-tag/custom-fields/)
 * [exclude](https://wordpress.org/support/topic-tag/exclude/)

 * 3 replies
 * 4 participants
 * Last reply from: [ditler](https://wordpress.org/support/users/ditler/)
 * Last activity: [10 years, 2 months ago](https://wordpress.org/support/topic/exclude-specific-custom-fields/#post-6176442)
 * Status: not resolved