0

I am trying to create alternating post styles for the homepage but can't seem to work it out.

I'd like to have full width image, followed by feature image left- post title right, then feature image right - post title left and back to the beginning again. Here are two examples similar to what I am hoping to do. http://www.loveshopshare.com/ http://shinebythree.com/

I am working off WooThemes Canvas. Also have Divi but it seems Canvas offers more control.

Thanks so much in advance.

0

You can add custom classes to each post. Here is a quick example of one approach:

add_action('post_class','YOURNAME_post_class');

function YOURNAME_post_class( $classes ) {

    global $wp_query;

    if( ! $wp_query->is_main_query() )
        return $classes;

    $classes[] = 'class-on-all-posts';
    if( 0 == $wp_query->current_post || 0 == $wp_query->current_post % 3 )
        $classes[] = 'class-on-every-third-post';
    if( 0 == $wp_query->current_post || 0 == $wp_query->current_post % 2 )
        $classes[] = 'class-on-every-second-post';
    return $classes;


}

You can then tweak the image and div alignment css based on the post classes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.