Guest User

Untitled

a guest
Jan 13th, 2016
107
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. add_filter('relevanssi_hits_filter', 'reviews_first');
  2. function reviews_first($hits) {
  3. $reviews = array();
  4. $releases = array();
  5. $everything_else = array();
  6. foreach ($hits[0] as $hit) {
  7. $review = false;
  8. foreach (get_the_category($hit->ID) as $cat) {
  9. if ($cat->cat_ID == 9) {
  10. $review = true;
  11. break;
  12. }
  13. $release = false;
  14. foreach (get_the_category($hit->ID) as $cat)
  15. if ($cat->cat_ID == 16) {
  16. $release = true;
  17. break;
  18. }
  19. }
  20. $review ? array_push($reviews, $hit) : array_push($everything_else, $hit);
  21. $release ? array_push($releases, $hit) : array_push($everything_else, $hit);
  22. }
  23.  
  24. $hits[0] = array_merge($reviews, $everything_else);
  25. $hits[0] = array_merge($releases, $everything_else);
  26. return $hits;
  27. }
RAW Paste Data