$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>Meta_query is not working on Elementor Custom Query Filter|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Meta_query is not working on Elementor Custom Query Filter

matteradmin7PV0评论
Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 6 years ago.

Improve this question

I’m following this tutorial to create a custom query filter.

I would like to filter by a metadata created by ACF (Advanced Custom Field), but it seems not working for me.

My code is like this:

add_action('elementor_pro/posts/query/my_custom_qurery', function($query) {
    $searchStr = get_search_query();

    $meta_query = [
        'key' => 'codigo_de_barra',
        'value' => $searchStr,
        'compare' => '=',
    ];

    $query->set('meta_query', $meta_query);
    $query->set('post_type', 'produto');
});

I’m using the widget “Posts” to display the results and I’m sure that I have set the custom query to Custom ID field, because the post_type is affecting results when I change it.

Why meta_query is not working?

Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 6 years ago.

Improve this question

I’m following this tutorial to create a custom query filter.

I would like to filter by a metadata created by ACF (Advanced Custom Field), but it seems not working for me.

My code is like this:

add_action('elementor_pro/posts/query/my_custom_qurery', function($query) {
    $searchStr = get_search_query();

    $meta_query = [
        'key' => 'codigo_de_barra',
        'value' => $searchStr,
        'compare' => '=',
    ];

    $query->set('meta_query', $meta_query);
    $query->set('post_type', 'produto');
});

I’m using the widget “Posts” to display the results and I’m sure that I have set the custom query to Custom ID field, because the post_type is affecting results when I change it.

Why meta_query is not working?

Share Improve this question asked Mar 3, 2019 at 14:36 Lai32290Lai32290 3512 gold badges4 silver badges15 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Meta query is an array containing arrays and not only one array (you can set multiple queries). So it should be:

$meta_query = [ [
    'key' => 'codigo_de_barra',
    'value' => $searchStr,
    'compare' => '=',
] ];
Post a comment

comment list (0)

  1. No comments so far