Home › Forums › Front-end Issues › order by sorting in relationship field › Reply To: order by sorting in relationship field
Try this:
<?php
// Query Arguments
$ids = get_field('relationship_name', false, false);
$args = array(
'post__in' => $ids,
'orderby' => 'post__in'
);
// The Query
$the_query = new WP_Query( $args);
// Check if the Query returns any posts
if ( $the_query->have_posts() ) {
php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<h1><?php the_field('postField_name'); ?></h1>
<?php endwhile; } ?>
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!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.