SHARE
TWEET

Untitled

a guest Jan 13th, 2016 80 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.         if ($review) array_push($reviews, $hit);
  21.         if ($release) array_push($releases, $hit);
  22.         if (!$review && !$release) array_push($everything_else, $hit);
  23.     }
  24.  
  25.     $hits[0] = array_merge($reviews, $releases, $everything_else);
  26.     return $hits;
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top