First post with different style and wrap every two posts
-
Hello everyone! First of all sorry me for my bad English but isn’t my native language so I’ll do as best as possible to explain my doubt.
I’ve a site running the last version of WordPress (4.4) and I want to display the post on the index.php page with two conditions.
– The first post must have a different style than the rest. AND
– Since that post I want to put a wrapper div after two posts.The graphical form is:
| FIRST POST DIFFERENT STYLE | | OPEN WRAPPER DIV | | OTHER POST| | OTHER POST | | CLOSE WRAPPER DIV | | OPEN WRAPPER DIV | | OTHER POST| | OTHER POST | | CLOSE WRAPPER DIV | | OPEN WRAPPER DIV | | OTHER POST| | OTHER POST | | CLOSE WRAPPER DIV |The code of my index.php page:
<?php if (have_posts()) : ?> <?php $post = $posts[0]; $c=0; ?> <?php query_posts($query_string . '&cat=1,2'); ?> <?php /* Start the Loop */ ?> <?php while (have_posts()) : the_post(); ?> <?php $c++; if( !$paged && $c == 1) :?> // FIRST POST STYLE HERE <?php else :?> <?php if( $wp_query->current_post%2 == 0 ) echo "\n".'<div class="wrap">open'."\n"; ?> <?php get_template_part( 'content', get_post_format() ); ?> <?php if( $wp_query->current_post%2 == 1 || $wp_query->current_post == $wp_query->post_count-1 ) echo 'close</div> <!--/.wrap-->'."\n"; ?> <?php endif;?> <?php endwhile; ?>The first post has a different style but the wrapper didn’t work. If anyone can help me will be great. Thanks very much in advance! =)
The topic ‘First post with different style and wrap every two posts’ is closed to new replies.