Hi,
It is default behaviour of wp_query. You can use the below code to display sticky post on top on archive page –
function prefix_sticky_first_order( $clauses, $query ) {
if ( !is_admin() && $query->is_main_query() && is_category() ) {
$sticky_posts = get_option('sticky_posts');
if ( !empty($sticky_posts) ) {
global $wpdb;
$sticky_ids = implode(',', array_map('intval', $sticky_posts));
$clauses['orderby'] = "
FIELD({$wpdb->posts}.ID, $sticky_ids) DESC,
{$wpdb->posts}.post_date DESC
";
}
}
return $clauses;
}
add_filter( 'posts_clauses', 'prefix_sticky_first_order', 10, 2 );
Dear Amit
Thank you very much. Works perfect.
Glad to hear that it works.