I am a php newbie and struggling to try and figure this one out. I have page where I am returning all the newsroom posts. The posts have a newsroom type that further divides them into Awards, Press Releases, In the News. I want to display the posts in groups so that all of the Press Releases show up first, then the awards and finally In the News. Within each group I want to further sort by date (newest first). Currently, I have this in my functions.php file to set up the query.
add_action( 'elementor/query/newsroom_order', function( $query ) {
$query->set( 'post_type', 'newsroom' );
$query->set( 'posts_per_page', '12'); // unable to override number on actual page
});
I'm using FacetWP as well. I've tried to do an orderby but it doesn't allow me to set the actual order.
These are the values:
- Taxonomy = newsroom_type
- post_type = newsroom
- slug OR term_id for:
- awards, 1822
- press_releases, 1812
- in_the_news, 1814
I'm hoping someone can tell me a good way to accomplish this.
newsroom
, based on your description 2 of the items you want to sort by are the same thing so there are 2 not 3 sorting criteria. Note that sorting by term is rare and not normal since a post can appear in more than one term making sorting very complicated if not impossible, normally people use multiple queries to solve this rather than a single query