First, thank you very much for this beautifully plugin! I love it! 🙂
At this moment i create a news page and every news/post has a custom field called ‘news_date’. The aim is to sort the news by that field. I’ve already read your documentation, but it will not work 🙁
Here is a piece of my template code:
$args = array( 'cat' => 3, 'posts_per_page' => 6, 'paged' => get_query_var('paged'), 'meta_key' => 'news_date', 'orderby' => 'meta_value_num', 'order' => ASC ); query_posts( $args ); while ( have_posts() ) : the_post(); $newsId = get_the_ID(); <div class="news"> ... <span class="news_date"><?php the_field('news_date', $newsId); ?></span> ... </div> endwhile;
Please tell me what’s wrong? :/
Tank you very much!
Thanks for answering.
My english is not the best, but i try to explain my problem.
I add a screenshot, here you can see the crazy order of my posts.
Yes, i’ve used your “how to” guide, but no matter what approach I use, it stays the same result.
The posts are not in order and the aim is to sort it like newest -to-> older ones. The newest post starts from 03.06.2013 and the oldest and last post have to be the 01.09.2011.
I dont know, whats going wrong, every post has a date field (Date Picker, save and display format: dd.mm.yy). When i remove the “meta_key” and “orderby” arguments, it changes the order. So i think the query reacts to this arguments …but nevertheless something is going wrong.
Thanks for trying to help me! 🙂
Oh, i recognize a pattern. He sorted only by the days and ignore the date as a whole. :/
I have change the save format back to yymmdd and edit the order in my template per
My own fail, sorry 😀
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
© 2019 Advanced Custom Fields. Subscribe