Support

Account

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
    }