Stick few posts on top and the rest order by date in particular category?
-
Hello, now i know how to order posts by date asc in a particular category:
function category_archive_sort_posts($query) { if ( !is_admin() && $query->is_main_query() ) { if ( is_category( 1192 ) ) { $query->set( 'orderby', 'date' ); $query->set( 'order', 'ASC' ); } } } add_action('pre_get_posts','category_archive_sort_posts');
but in this function how can i add say 3 posts from the same category to be on the top of the page (like sticky or featured posts) and the rest ordered by date? I think it should be with ‘post__in’ but i don’t know how.
- The topic ‘Stick few posts on top and the rest order by date in particular category?’ is closed to new replies.