I am generating a Featured Content with the following code:
<?php
$featured_posts = get_featured_posts();
foreach ( (array) $featured_posts as $order => $post ) :
setup_postdata( $post );
get_template_part( 'content', 'featured-post' );
endforeach;
?>
The page looks like this, sorted by ID:
<article id="post-201">...</article>
<article id="post-204">...</article>
<article id="post-227">...</article>
<article id="post-331">...</article>
<article id="post-530">...</article>
<article id="post-633">...</article>
<article id="post-759">...</article>
I need to sort by Page Order instead. Is this code OK for this purpose?. This works OK.
usort($featured_posts, function($a, $b) {
return $a->menu_order - $b->menu_order;
});
get_featured_posts()
function? Never seen it before and can't find it in the WordPress documentation anywhere.