Home › Forums › General Issues › Order by custom field › Reply To: Order by custom field
Thanks John.
I thought about the consequences of doing it this way too, where each post would have to be edited one by one. I still thought it would be better, rather than having a separate page which is ‘disconnected’ from the posts. But after some more thought, I agree with you.
So I set up a relationship field, set it to posts and the ‘featured’ category and the Return Format as Post ID. With the following code I got it to work (only posting this in case it is useful for someone else):
<?php
$posts = get_field('feature_ordering', 109); //Page ID number
if( $posts ):
foreach( $posts as $post):
setup_postdata($post); ?>
<div class="featured">
<?php the_title(); //etc... ?>
</div>
<?php endforeach;
wp_reset_postdata();
endif;
?>
Thanks again though for the code and for making me go with the better way 🙂
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.