Hi! I have ACF set up to have “Game” posts list other posts manually selected by the admin through a “compatible_amiibo” relationship field. However, when displayed on the “Game” post, all the listed “compatible_amiibo” posts are organized by when they were selected by the admin, so newly-selected posts are listed last. I would prefer to have these posts sorted alphabetically/by title.
I have very limited PHP knowledge and I’ve tried Googling and searching these forums for answers. Nothing I’ve tried has worked, so I’m hoping I can get some more direct advice here!
This is what I have in my template:
<?php
$posts = get_field('compatible_amiibo');
if( $posts ): ?>
<?php foreach( $posts as $post): // variable must be called $post (IMPORTANT) ?>
<?php setup_postdata($post); ?>
<div class="product">
<a href="<?php echo the_permalink(); ?>"><img src="<?php echo the_post_thumbnail(); ?><?php the_title( '<h3>', '</h3>' ); ?></a>
</div>
<?php endforeach; ?>
<?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
</div>
<?php endif; ?>
Thank you in advance for any help! I appreciate it!