Support

Account

Forum Replies Created

  • I’m not sure if I understood correctly, maybe could I have a little example please?
    Thanks in advance

  • Hi, thanks for the answer. Your solution has fixed the problem but I notice a strange behaviour.

    Essentially, if I remove this line:

    $query->query_vars[‘s’] = ”;

    I doesn’t get any result. I would like to return all the posts which contains a certain meta, and also match as title or content the searched term.

    Is there something else broken in my code?

  • Hi, I’m trying to include in the WordPress search the repeater field, essentially I have this situation:

    There is a cpt called “service” which can have multiple “doctor” (cpt), each “doctor” is associated through the repeater field “medici”, infact if I inspect the postmeta table I have this:

    as you can see I have a list of ids in the “medici” meta_key.
    So suppose that I have this situation: a “service” with post_title “lorem ipsum”, to this “service” are linked a list of “doctor” eg: (paolini, rossi, mario). I would like that if I search for “paolini”, I will get the “lorem ipsum” post.

    So I wrote this code:

    `
    function add_acf_to_search( $query ) {
    if( $query->is_search ) {
    $query->set( ‘meta_query’, array(
    ‘relation’ => ‘OR’,
    array(
    ‘key’ => ‘medici’,
    ‘value’ => $query->query_vars[‘s’],
    ‘compare’ => ‘LIKE’
    )
    ));
    }
    }
    add_action( ‘pre_get_posts’, ‘add_acf_to_search’ );
    `

    the problem’s that if I search for a “doctor” linked to a “service” I doesn’t get any result.

    Any idea?

    PS: I don’t want use any plugin.

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