Support » Theme: Tracks » "even/odd" classes and custom queries

  • Resolved _CarlosTheDwarf_

    (@_carlosthedwarf_)


    Greetings! Thanks for the awesome theme!

    I have a custom home.php template that displays only posts in a custom post type on my homepage. But I’ve found that creating a new WP_Query to grab theses breaks the nifty “even/odd” class assigned to the posts in succession, so the featured images and excerpts now all fall on the same side, instead of being alternated. Can anybody help?

    Here’s what I think the relevant function is:

    function ct_tracks_odd_even_post_class( $classes ) {

    // access the post object
    global $wp_query;

    // add even/odd class
    $classes[] = ($wp_query->current_post % 2 == 0) ? ‘odd’ : ‘even’;

    // add post # class
    $classes[] = “excerpt-” . ($wp_query->current_post + 1);

    return $classes;
    }
    add_filter ( ‘post_class’ , ‘ct_tracks_odd_even_post_class’ );

Viewing 2 replies - 1 through 2 (of 2 total)
  • Nevermind. Realized I actually renamed my custom query to something other than $wp_query.

    One of those days.

    Again, thanks for this amazing theme!

    Theme Author Ben Sibley

    (@bensibley)

    Glad you figured it out 🙂

    If you need anything else, don’t hesitate to ask here.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘"even/odd" classes and custom queries’ is closed to new replies.