按自定义字段日期的数组排序

时间:2014-09-05 作者:Paul

我想按一个名为date_start 但是,如果我已经有了一个元密钥,那么如何为其包含一个元密钥呢?

$currentshowid = get_the_ID();
$today = date(\'Y-m-d\');
$args = array(
    \'meta_key\' => \'show_id\',
    \'meta_value\' => $currentshowid,
    \'orderby\' => \'meta_value_num\',
    \'order\' => ASC,
    \'meta_query\' =>array(
        \'relation\' => \'AND\',
        array(
            \'key\' => \'date_end\',
            \'value\' => $today,
            \'compare\' => \'>=\',
        ),
    ),
);

1 个回复
SO网友:Chinmoy Kumar Paul

您需要为自定义字段使用类型参数。试试这个

<?php 
$currentshowid = get_the_ID();
$today = date(\'Y-m-d\');
$args = array(
              \'meta_key\' => \'show_id\',
              \'meta_value\'  => $currentshowid,
              \'orderby\' => \'meta_value_num\',
              \'order\' => ASC,
              \'meta_query\' =>array(
                                \'relation\' => \'AND\',
                                array(
                                \'key\'       => \'date_end\',
                                \'value\'   => $today,
                                \'compare\'   => \'>=\', 
                                \'type\'    => \'date\'                               
                                ),
                            ),
          ); 

结束

相关推荐

如何修复警告:CALL_USER_FUNC_ARRAY()?

我修改了我的主题元盒。php来满足我的需要,我得到了这个Blockquote警告:call\\u user\\u func\\u array()要求参数1为有效回调,在E:\\xampp\\htdocs\\wordpress\\wp includes\\plugin中找不到函数“mytheme\\u add\\u box”,或函数名无效。php第406行Blockquote我怎样才能修复它?这是我的旧metabox代码<?php $prefix = \'wtf_\'; $m

按自定义字段日期的数组排序 - 小码农CODE - 行之有效找到问题解决它

按自定义字段日期的数组排序

时间:2014-09-05 作者:Paul

我想按一个名为date_start 但是,如果我已经有了一个元密钥,那么如何为其包含一个元密钥呢?

$currentshowid = get_the_ID();
$today = date(\'Y-m-d\');
$args = array(
    \'meta_key\' => \'show_id\',
    \'meta_value\' => $currentshowid,
    \'orderby\' => \'meta_value_num\',
    \'order\' => ASC,
    \'meta_query\' =>array(
        \'relation\' => \'AND\',
        array(
            \'key\' => \'date_end\',
            \'value\' => $today,
            \'compare\' => \'>=\',
        ),
    ),
);

1 个回复
SO网友:Chinmoy Kumar Paul

您需要为自定义字段使用类型参数。试试这个

<?php 
$currentshowid = get_the_ID();
$today = date(\'Y-m-d\');
$args = array(
              \'meta_key\' => \'show_id\',
              \'meta_value\'  => $currentshowid,
              \'orderby\' => \'meta_value_num\',
              \'order\' => ASC,
              \'meta_query\' =>array(
                                \'relation\' => \'AND\',
                                array(
                                \'key\'       => \'date_end\',
                                \'value\'   => $today,
                                \'compare\'   => \'>=\', 
                                \'type\'    => \'date\'                               
                                ),
                            ),
          ); 

相关推荐

警告:CALL_USER_FUNC_ARRAY()要求参数1是有效的回调

我创建了一个新的wordpress,没有主题,只有一个插件:GDPR WP。(我想先在空wordpress上试用这个插件,然后再将它部署到其他网站上)。所以,我第一次尝试创建函数来接受或不接受GoogleAnalytics cookie。我的函数工作正常,但在BO/FO上有一个错误:Warning: call_user_func_array() expects parameter 1 to be a valid callback, function \'cookie_GA\' not found or i