Advertisement
ETFovac

Untitled

Nov 30th, 2014
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.53 KB | None | 0 0
  1. function stickies_and_old($posts)
  2. {
  3.     if (is_category() || is_tag() )
  4.         $posts = sort_stickies($posts);
  5.     else
  6.         return $posts;
  7.  
  8.     return $posts;
  9. }
  10.  
  11. add_filter('the_posts','stickies_and_old');
  12.  
  13. function sort_stickies($posts)
  14. {
  15.     $sposts = array();
  16.     $stickies = get_option('sticky_posts');
  17.  
  18.  
  19.     foreach($posts as $post_index => $dpost):
  20.         if (in_array($posts[$post_index]->ID,$stickies)) :
  21.             $sposts[] = $dpost;
  22.             unset($posts[$post_index]);
  23.         endif;
  24.     endforeach;
  25.     $posts = array_merge($sposts,$posts);
  26.     return $posts;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement