wp query - WP_Query with 4 post meta field arguments gives 500 internal server error

I am creating a custom plugin to search for custom post type provided with 4 meta field arguments.I am using wp_Query()

I am creating a custom plugin to search for custom post type provided with 4 meta field arguments. I am using wp_Query() to fetch the search results. My Query string is.

            $args = array(
            'update_post_meta_cache' => false,
            'cache_results' => false,
            'post_type' => 'caravans',
            'meta_query' => array(
                'relation' => 'OR',
                array(
                    'key' => 'caravan_used_new',
                    'value' => $used,
                    'compare'=>'like',
                ),
                array(
                    'key' => 'caravan_or_motorhome',
                    'value' => $type,
                    'compare'=>'like',
                ),
                array(
                    'key' => 'caravan_berth',
                    'value' => $bearth,
                    'compare'=>'like',
                ),
                array(
                    'key' => 'caravan_make',
                    'value' => $make,
                    'compare'=>'like',
                ),
            )
        );
        if(!empty($key)){
            $wp_query = new WP_Query("s=$key", $args);
        }else{
            $wp_query = new WP_Query($args);
        }

Now it is working good if I put only three meta_Query arguments when I make it to 4 its start crashing and all I see in 500 internal server error. Am I doing something wrong or meta_query has its own limits?

I am creating a custom plugin to search for custom post type provided with 4 meta field arguments. I am using wp_Query() to fetch the search results. My Query string is.

            $args = array(
            'update_post_meta_cache' => false,
            'cache_results' => false,
            'post_type' => 'caravans',
            'meta_query' => array(
                'relation' => 'OR',
                array(
                    'key' => 'caravan_used_new',
                    'value' => $used,
                    'compare'=>'like',
                ),
                array(
                    'key' => 'caravan_or_motorhome',
                    'value' => $type,
                    'compare'=>'like',
                ),
                array(
                    'key' => 'caravan_berth',
                    'value' => $bearth,
                    'compare'=>'like',
                ),
                array(
                    'key' => 'caravan_make',
                    'value' => $make,
                    'compare'=>'like',
                ),
            )
        );
        if(!empty($key)){
            $wp_query = new WP_Query("s=$key", $args);
        }else{
            $wp_query = new WP_Query($args);
        }

Now it is working good if I put only three meta_Query arguments when I make it to 4 its start crashing and all I see in 500 internal server error. Am I doing something wrong or meta_query has its own limits?

Share Improve this question edited Jun 30, 2020 at 22:56 mozboz 2,6281 gold badge12 silver badges23 bronze badges asked Jul 3, 2013 at 6:03 Abhimanue TamangAbhimanue Tamang 1691 silver badge8 bronze badges 0
Add a comment  | 

1 Answer 1

Reset to default 1

I found solution to my problem by replicating the whole setup to my local server. Everything worked fine query executed normally. And the bug was memory allocated for PHP execution which i come to know by comparing the local and live server. So for that I declared two lines in the header part of the file.

set_time_limit(0);
ini_set("memory_limit", "1024M");

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742304312a4418629.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信