Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Only add the 'post_class' filters on the appropriate pages.
- // The is_front_page() test was returining an incorrect value on non-front pages!!
- add_action('get_header', 'mcl_add_post_class_filters');
- function mcl_add_post_class_filters() {
- if (is_front_page()) {
- add_filter( 'post_class', 'mcl_front_page_sidebar_post_class' );
- }
- if (is_category()) {
- add_filter( 'post_class', 'be_archive_post_class' );
- }
- }
- // Change the front page sidebar items to be in 3 columns.
- function mcl_front_page_sidebar_post_class( $classes ) {
- global $wp_query;
- if($wp_query->is_main_query() ) {
- return $classes;
- }
- if (!is_front_page()) {
- return $classes;
- }
- $classes[] = 'one-third';
- if( 0 == $wp_query->current_post || 0 == $wp_query->current_post % 3 )
- $classes[] = 'first';
- return $classes;
- }
- // Set the category archive posts to be in 2 columns.
- /**
- * Archive Post Class
- * @since 1.0.0
- *
- * Breaks the posts into two columns
- * @link http://www.billerickson.net/code/grid-loop-using-post-class
- *
- * @param array $classes
- * @return array
- */
- function be_archive_post_class( $classes ) {
- global $wp_query;
- if( ! $wp_query->is_main_query() ) {
- return $classes;
- }
- if (!is_category()) {
- return $classes;
- }
- $classes[] = 'one-half';
- if( 0 == $wp_query->current_post || 0 == $wp_query->current_post % 2 )
- $classes[] = 'first';
- return $classes;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement