mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-29 11:32:21 +08:00
15 lines
414 B
Text
15 lines
414 B
Text
add_filter( 'relevanssi_hits_filter', 'rlv_sticky_first' );
|
|
function rlv_sticky_first( $hits ) {
|
|
$sticky = array();
|
|
$nonsticky = array();
|
|
$sticky_post_ids = get_option( 'sticky_posts' );
|
|
foreach( $hits[0] as $hit ) {
|
|
if ( in_array( $hit->ID, $sticky_post_ids ) ) {
|
|
$sticky[] = $hit;
|
|
} else {
|
|
$nonsticky[] = $hit;
|
|
}
|
|
}
|
|
$hits[0] = array_merge( $sticky, $nonsticky );
|
|
return $hits;
|
|
}
|