Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created December 17, 2012 15:51
Show Gist options
  • Select an option

  • Save billerickson/4319329 to your computer and use it in GitHub Desktop.

Select an option

Save billerickson/4319329 to your computer and use it in GitHub Desktop.
<?php
/**
* Add row classes to the archive pages
*
* @param array $classes
* @return array $classes
*/
function be_row_classes( $classes ) {
// Only run on archive pages
if( is_singular() )
return $classes;
global $wp_query;
if( 0 == $wp_query->current_post )
$classes[] = 'row-1';
if( 1 == $wp_query->current_post )
$classes[] = 'row-2';
if( 2 == $wp_query->current_post )
$classes[] = 'row-3';
if( 3 == $wp_query->current_post )
$classes[] = 'row-4';
if( in_array( $wp_query->current_post, array( 4, 5 ) )
$classes[] = 'row-5';
if( in_array( $wp_query->current_post, array( 6, 7 ) )
$classes[] = 'row-6';
return $classes;
}
add_filter( 'body_class', 'be_row_classes' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment