Advertisement
srikat

Untitled

May 13th, 2015
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. add_action( 'pre_get_posts', 'sk_portfolio_archive_random' );
  2. /**
  3. * Set Random order for entries in Portfolio archive page
  4. *
  5. * @author Bill Erickson
  6. * @author Sridhar Katakam
  7. * @link http://www.billerickson.net/customize-the-wordpress-query/
  8. * @param object $query data
  9. *
  10. */
  11. function sk_portfolio_archive_random( $query ) {
  12.  
  13. if( $query->is_main_query() && !is_admin() && is_post_type_archive( 'portfolio' ) ) {
  14. $query->set( 'orderby', 'rand' );
  15. }
  16.  
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement