acf wordpress loop through and display blog posts order by date and type

To loop through and display blog posts ordered by date and type in Wordpress using Advanced Custom Fields (ACF), you can use the following code:

$args = array(
    'post_type' => 'post',
    'meta_key'  => 'type', // Replace 'type' with the name of your ACF field
    'orderby'   => array( 'date' => 'DESC', 'meta_value' => 'ASC' ),
);

$query = new WP_Query( $args );

if ( $query->have_posts() ) {
    while ( $query->have_posts() ) {
        $query->the_post();
        // Display the blog post content here
        the_title();
        the_content();
    }
    wp_reset_postdata();
} else {
    // No posts found
}

Explanation: 1. We define the arguments for the WP_Query, including the post type and the meta key for the custom field. 2. We use the WP_Query to retrieve the posts based on the specified arguments. 3. We loop through the retrieved posts using a while loop, and use the_post() to set up the post data for the current post. 4. Inside the loop, you can display the content of the blog post using functions like the_title() and the_content(). 5. After the loop, we reset the post data using wp_reset_postdata().