Given certain posts on blog page, their own class
-
Hello,
I am trying to achieve this particular layout for my posts on my blog page/homepage I hope this makes sense:
|Most recent post fills whole content area|
|2nd Post half the size| |3rd post half the size|
|4th Post half size| |5th post half size|
|6th post fills whole content area|
|7th Post half size| |8th post half size|
|9th Post half size| |10th post half size|
|11th post fills whole content area|
|12th Post half size| |13th post half size|
|14th Post half size| |15th post half size|
|16th post fills whole content area|
|17th Post half size| |18th post half size|
|19th Post half size| |20th post half size||Ajax Load Post Plugin goes here to load more posts|
I am currently using twenty twelve (child theme).
I have tried using the transformationpowertools method:
<article id="post-<?php the_ID(); ?>" <?php $extra = ( $wp_query->current_post % 5 && !is_paged() ) ? 'specialclass' : ''; post_class($extra); ?>>
And this takes every 5 posts and assigns a class to the last 4 of them and this works great. However when i float these classes left in my CSS so they display next to each other I cannot add a margin to the right of the first half sized post and the left of the second:
|1st Half sized post|margin margin |2nd half sized post|
Unless there is something I am not thinking of I am going to have add one class to the half sized posts on the left and a separate class to the ones on the right:
|Most recent post fills whole content area|
|special class 1| |special class 2|
|special class 1| |special class 2|
|6th post fills whole content area|
|special class 1| |special class 2|
|special class 1| |special class 2|
|11th post fills whole content area|
|special class 1| |special class 2|
|special class 1| |special class 2|
|16th post fills whole content area|
|special class 1| |special class 2|
|special class 1| |special class 2|Can anyone tell me how I can do this?
- The topic ‘Given certain posts on blog page, their own class’ is closed to new replies.