Advertisement
srikat

Untitled

Sep 13th, 2016
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. /**
  2. * Display as Columns
  3. *
  4. */
  5. function be_portfolio_post_class( $classes ) {
  6.  
  7. if ( is_main_query() ) { // conditional to ensure that column classes do not apply to Featured widgets
  8. $columns = 3; // Set the number of columns here
  9.  
  10. $column_classes = array( '', '', 'one-half', 'one-third', 'one-fourth', 'one-fifth', 'one-sixth' );
  11. $classes[] = $column_classes[$columns];
  12. global $wp_query;
  13. if( 0 == $wp_query->current_post || 0 == $wp_query->current_post % $columns )
  14. $classes[] = 'first';
  15. }
  16.  
  17. return $classes;
  18. }
  19. add_filter( 'post_class', 'be_portfolio_post_class' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement