Sort by category and then date on WordPress homepage

My WordPress site has multiple custom categories and posts types all which need to be displayed on the home page blogroll. But I need the first post on the homepage always to be the most recent post from a specific category.

For example the pst at the top of the page will always be the latest “giraffe” category; and below it; sorted default/chronologically are more “walrus” mixed with “seagull” and “nachos”

Read More

What would be the best way to accomplish this?

Related posts

Leave a Reply

1 comment

  1. Without running through the Loop twice, sticky posts are your best option.

    Otherwise:

    ...
    $args = array(
     'orderby' => 'post_date',
     'category'=> 'giraffe',
     'numberposts'=> 1,
    );
    $latest_giraffe_post = get_posts( $args );    
    ... 
    

    then do what you’re already doing for the rest