Orderby ACF自定义字段日期无效 [英] Orderby ACF custom field date don't work
本文介绍了Orderby ACF自定义字段日期无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我查看了另一篇文章,但什么都没找到,我已经三天了:
I view the other post but I found nothing, I'm on since 3 days :
我要按<$ c $的顺序显示3个 evenements c> ASC
,但2018年总是在2017年之前
I want display 3 'evenements' in the order ASC
but 2018 is always before 2017
$auj = date('Ymd');
$queryEvent = new WP_Query(
array(
'category_name' => 'evenements',
'posts_per_page' => 3,
'meta_key' => 'date_de_fin',
'orberby' => 'meta_key',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => 'date_de_fin',
'value' => $auj,
'compare' => '>=',
),
)
)
);
?>
有人有想法吗?
推荐答案
我通过SQL查询解决问题:
I resolve by problem with a SQL query :
$queryEvent = $wpdb->get_results( 'SELECT * FROM cci_posts INNER JOIN cci_postmeta ON cci_posts.id = cci_postmeta.post_id INNER JOIN cci_term_relationships ON cci_posts.id = cci_term_relationships.object_id WHERE cci_term_relationships.term_taxonomy_id = 4 AND cci_postmeta.meta_key = "date_de_fin" AND cci_postmeta.meta_value > 20170221 AND cci_posts.post_status = "publish" ORDER BY cci_postmeta.meta_value ASC LIMIT 3', OBJECT );
//$queryEvent = new WP_Query($args);
?>
<?php if ( $queryEvent ) : ?>
<?php /* Start the Loop */ ?>
<?php foreach ($queryEvent as $post) {
setup_postdata($post); ?>
这篇关于Orderby ACF自定义字段日期无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文