Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created December 21, 2015 17:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billerickson/16bee44567fe30c9de52 to your computer and use it in GitHub Desktop.
Save billerickson/16bee44567fe30c9de52 to your computer and use it in GitHub Desktop.
<?php
function be_portfolio_post_class( $classes ) {
<!-- I dont understand this part-->
global $wp_query;
if( !$wp_query-&gt;is_main_query() )
return $classes;
<!-- End-->
$columns = 3;
<!-- I dont understand this part-->
$column_classes = array( '', '', 'one-half', 'one-third', 'one-fourth', 'one-fifth', 'one-sixth' );
$classes[] = $column_classes[$columns];
if( 0 == $wp_query-&gt;current_post % $columns )
$classes[] = 'first';
return $classes;
<!-- End-->
}
add_filter( 'post_class', 'be_portfolio_post_class' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment