按标题和元搜索查询参数

Search query parameters by title and meta

请帮我创建用于按标题和元搜索的查询参数, 示例:
项目:
1 - 标题:公司,内容:asdf,meta_field_vendor:asd
2 - 标题:comp,内容:公司,meta_field_vendor:asd
3 - 标题:ttcmp,内容:asdf,meta_field_vendor:asd
4 - 标题:myrus,内容:asdf,meta_field_vendor:公司

我的搜索字符串 ?s=company

我要搜索的结果是项目:1,2,4

这个查询参数

$args['wp_query'] = array(
    'post_type' => $post_type,
    'posts_per_page' => 5,
    's' => $search_s,
);

结果 1 和 2

这个查询参数

$args['wp_query'] = array(
    'post_type' => $post_type,
    'posts_per_page' => 5,
    'meta_query' => array (
        array(
            'key' => '_item_prop_title',
            'value' => $search_s,
            'compare' => 'EXISTS'
        )
    )
);

结果 4

如何查询结果 1、3、4?

$args['wp_query'] = array(
    'post_type' => $post_type,
    'posts_per_page' => 5,
    's' => $search_s,
    'meta_query' => array (
        array(
            'key' => '_item_prop_title',
            'value' => $search_s,
            'compare' => 'EXISTS'
        )
    )
);

干杯!

你可以为你的问题做的是双重搜索过程,如果它不是最佳响应但如果它有效...

 $search_s = 'mykeyword';

    $q1 = get_posts(array(
        'post_type' => 'post',
        's' => $search_s
    ));

    $q2 = get_posts(array(
            'post_type' => 'post',
            'meta_query' => array(
                array(
                   'key' => 'my_meta_box',
                   'value' => $search_s,
                   'compare' => 'LIKE'
                )
             )
    ));

    $merged = array_merge( $q1, $q2 );

    $post_ids = array();
    foreach( $merged as $item ) {
        $post_ids[] = $item->ID;
    }

    $unique = array_unique($post_ids);

    $posts = get_posts(array(
        'post_type' => 'post',
        'post__in' => $unique,
        'post_status' => 'publish',
        'posts_per_page' => -1
    ));

    if( $posts ) : foreach( $posts as $post ) :
        setup_postdata($post);

        the_title();


    endforeach; 
    endif;

你试过类似的东西吗?:

$args['wp_query'] = array(
    'post_type' => $post_type,
    'posts_per_page' => 5,
    's' => $search_s,
    'meta_query' => array(
        array(
            'key'       => '_item_prop_title',// Name of the key you want to search. Check your BD to be sure this is the correct name
            'value'     => $search_s,
            'compare'   => 'LIKE',// You can use '=' instead if you want to be more restrictive.
        ),
    ),
);