Searching Jet Engine Custom Meta Storage fields

How to search within custom table fields in Jet Engine Post Types

Jet engine 3.4 added a feature to store custom fields in separate tables for post types created by Jet Engine. This is a great feature, and integrates well with WordPress.

Because these fields are stored outside of the metadata table, a small custom code snippet is required to fetch the contents and append to the index table:

  • Make sure to safely use this code, please read this guide for how and where to put it

  • Add the custom field names to the $jet_custom_fields variable (on line 5), line-by-line, use the existing values as a template

  • Configure and enable the index table engine so the field values are indexed. You will notice that you can't find these fields to index, but do not worry, the custom code will cover that.

  • Enjoy 😄

add_action(
	'asp_it_args',
	function ($args) {
		// Add the fields to this array
		$jet_custom_fields = array(
			'jet_meta_field1',
			'jet_meta_field2',
		);

		// --------------------------------------------
		// --- DO NOT CHANGE ANYTHING BELOW
		if( is_array($args['index_customfields']) ) {
			$args['index_customfields'] = array_merge(
				$args['index_customfields'],
				$jet_custom_fields
			);
		} else {
			$jet_custom_fields = implode('|', $jet_custom_fields);
			$args['index_customfields'] =
				$args['index_customfields'] == '' ?
					$jet_custom_fields :
					$args['index_customfields'] . '|' . $jet_custom_fields;
		}
		return $args;
	},
	10,
	1
);

Last updated

Copyright Ernest Marcinko