Home › Forums › General Issues › Displaying grouped content › Reply To: Displaying grouped content
This isn’t something that ACF will do automatically, you’ll need to handle this with your query and loop.
WP 4.0 and 4.2 introduced better ordering.
For the latest change, see this post: https://make.wordpress.org/core/2015/03/30/query-improvements-in-wp-4-2-orderby-and-meta_query/
As for the enhanced orderby see the orderby section codex page for WP_Query or this post: https://make.wordpress.org/core/2014/08/29/a-more-powerful-order-by-in-wordpress-4-0/
First you need to get them ordered correctly. This will output them in the right order, then you can create a custom loop that will do the work.
Here is an example of a simple loop that will do the separating.
$last_brand = '';
$this_brand = '';
while (have_poste()) {
the_post();
$this_brand = get_field('brand');
if ($this_brand != $last_brand) {
// change brands
}
$last_brand = $this_brand;
// rest of the loop here
}
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!
🤔 Curious about the ACF user experience? So are we! Help guide the evolution of ACF by taking part in our first ever Annual Survey and guarantee you’re represented in the results. https://t.co/0cgr9ZFOJ5
— Advanced Custom Fields (@wp_acf) May 8, 2023
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.