Meta Box
Integrate with the Meta Box plugin
This free add-on integrates FacetWP with Meta Box, allowing you to use Meta Box custom fields for front-end search and filtering.
For an e-commerce or listing website, the product or listing requires custom data such as price, location, color, etc. And users need to search or filter the products / listings in the frontend based on these criteria.
With the help of Meta Box, you can create any kind of data (custom fields) for your product / listing or any custom post type.
Installation
- Download the add-on from the Meta Box website
- Install and activate FacetWP, Meta Box, and this add-on
- Browse to Settings > FacetWP to add a new facet
- Within the facet’s “Data source” dropdown, you’ll see new Meta Box-specific options
Usage
When selecting Meta Box fields in facets’ data source fields, make sure to select the fields under the “Meta Box” heading in the dropdown:
More info
More info about using Meta Box with FacetWP can be found on this “Meta Box – FacetWP Integrator” page.
Fix indexing issues when using Meta Box with WPML
If you are using Meta Box custom fields as facets’ data source, and you are translating these fields with WPML (with the Multilingual add-on installed), you may see issues with translated posts not being indexed after they are edited.
This issue happens for Meta Box fields that are set to “Copy” instead of “Translate”, in WPML’s Custom Fields Translation settings:
Meta Box fields set to “Copy” get deleted and recreated on updating a post. The recreate happens after FacetWP’s (re-)indexing of the post, leading to the post not being indexed anymore for those fields.
The following snippet should keep this from happening. Make sure to re-index after adding this snippet to your (child) theme’s functions.php:
How to use custom PHP code?
PHP code can be added to your (child) theme's functions.php file. Alternatively, you can use the Custom Hooks add-on, or a code snippets plugin. More info
<?php add_filter( 'rwmb_text_html', function( $html ) { return str_replace( 'disabled', 'readonly', $html ); }, 10 );