Advertisement
msaari

Relevanssi sticky posts

Aug 8th, 2012
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. add_filter( 'relevanssi_hits_filter', 'my_stickyposts_hits_filter' );
  2.  
  3. function my_stickyposts_hits_filter( $data ) {
  4.     $hits = $data[0];
  5.     $regularposts = array();
  6.     $stickyposts = array();
  7.     $query = $data[1];
  8.  
  9.     foreach ( $hits as $key => $hit ) {
  10.         if ($hit->ID == X && $query == "Y")
  11.             $stickyposts[] = $hit;
  12.         else $regularposts[] = $hit;
  13.     }
  14.  
  15.     $filtered_hits = array_merge($stickyposts, $regularposts);
  16.     $filtered_data = array( $filtered_hits, $data[1] );
  17.  
  18.     return $filtered_data;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement