Custom Fields
Re-Envisioned
Support General Metaboxes searchable? Reply To: Metaboxes searchable?

#11125

Ale
Participant

Thanks Anh,

I’m not sure why it isn’t working but when I add the code from the tutorial to my functions.php it simply doesn’t change the results at all.

If I add teh following code, then the search is broken and I can’t find anything at all.

add_action( 'pre_get_posts', function( $query ) {
    if ( is_admin() || ! $query->is_main_query() ) {
        return;
    }
    $query->set( 'meta_query', [
        'relation' => 'OR',
        [
            'key' => 'mb_someidused',
            'value' => '"' . get_search_query()  . '"',
            'compare' => 'LIKE'
        ]
    ] );
} );