Support

Account

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 🙂