Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Wordpress AJAX加载更多Orderby Meta\u VALUE\u NUM_Php_Ajax_Wordpress - Fatal编程技术网

Php Wordpress AJAX加载更多Orderby Meta\u VALUE\u NUM

Php Wordpress AJAX加载更多Orderby Meta\u VALUE\u NUM,php,ajax,wordpress,Php,Ajax,Wordpress,你好, 我的自定义帖子中有多个meta_键值对。为了解决这个问题,我首先运行了一个WP_查询,它创建了一个posts ID数组,然后传递给load more来加载它们 我使用WP_查询构建的数组顺序正确。但是,当我在post_in参数中使用ID时,它不会按给定顺序显示它们。我也试着给出参数,但它也不起作用 这里是WP_查询,它工作得很好 $loop = new WP_Query( array(

你好, 我的自定义帖子中有多个meta_键值对。为了解决这个问题,我首先运行了一个WP_查询,它创建了一个posts ID数组,然后传递给load more来加载它们

我使用WP_查询构建的数组顺序正确。但是,当我在post_in参数中使用ID时,它不会按给定顺序显示它们。我也试着给出参数,但它也不起作用

这里是WP_查询,它工作得很好

$loop = new WP_Query( 
                                array( 
                                      'post_type' => 'properties', 
                                      'posts_per_page' => -1,
                                        'meta_query' => array(
                                                array(
                                                    'key' => 'listing_type',
                                                    'value'   => array(3,2),
                                                    'type'   => 'NUMERIC',
                                                ),
                                                array(
                                                    'key'     => 'payment_status',
                                                    'value'   => 'yes',

                                                        ),                                              
                                                array(
                                                    'key'     => 'expired',
                                                    'value'   => 'no',



 - ),

                        ),
                                        'orderby' => 'meta_value_num',
                                        'meta_key' => 'listing_type',
                                        'order' => 'DESC' 
                                      )); 
以下是短代码:

[ajax_load_more post_type="properties" post__in="'.implode(',',$featured).'" posts_per_page="10" scroll="false" transition="fade" button_label="'.$l_more.'" button_loading_label="'.$l_more_2.'" container_type="ul" css_classes="items",orderby="meta_value_num" meta_key="listing_type"]
然而,它并没有按应有的顺序排列帖子,因为$featured数组按要求的顺序排列。即使我删除了orderby和meta_键参数,它也不起作用

请帮忙
Ahmar

首先,您的短代码中有一个错误

[ajax_load_more post_type="properties" post__in="'.implode(',',$featured).'" posts_per_page="10" scroll="false" transition="fade" button_label="'.$l_more.'" button_loading_label="'.$l_more_2.'" container_type="ul" css_classes="items" orderby="meta_value_num" meta_key="listing_type"]
其次,您应该
orderby=“post\uu in”
以保留
post\uu in
排序。

首先,您的短代码中有一个错误

[ajax_load_more post_type="properties" post__in="'.implode(',',$featured).'" posts_per_page="10" scroll="false" transition="fade" button_label="'.$l_more.'" button_loading_label="'.$l_more_2.'" container_type="ul" css_classes="items" orderby="meta_value_num" meta_key="listing_type"]
其次,您应该
orderby=“post\uu in”
以保留
post\uu in
排序。

如果您回显$loop,查询会说什么?“但是它没有按应有的顺序排列帖子,因为$featured数组按要求的顺序排列。”–它“应该”这样做,这只是您的假设。按id选择帖子本身并不能保证任何顺序。@WouterNeuteboom查询完全按照预期工作,并以正确的顺序返回id。然而,ajax负载更多的是不排序数据correctly@CBroe正如您在shortcode中看到的,meta_key meta_value_num没有这样做。好吧,我会先尝试使用正确的shortcode语法…逗号在那里做什么?如果您回显$loop,查询会说什么?“然而,它并没有按它应该的顺序排列帖子,因为$featured数组按要求的顺序排列。”–它“应该”这样做,这只是你的假设。按id选择帖子本身并不能保证任何顺序。@WouterNeuteboom查询完全按照预期工作,并以正确的顺序返回id。但是,ajax加载的更多内容不是对数据排序correctly@CBroe正如您在shortcode中看到的,meta_键meta_value_num并没有这样做,我会尝试使用它首先是正确的短码语法…逗号在那里做什么?非常感谢@darrent谢谢@Darren