• greg9885

    (@greg9885)


    Here’s what I’m trying to accomplish in my index.php file:
    1 Featured Post only on the Home Page (can’t use sticky function because it has needs more options)
    8 Other “Regular” Posts on the Home Page (12 on the rest of the indexed pages, ie:page 2, page 3, page 4, etc…)
    – These posts will each have an individual tag that says “IF TAGGED ARTICLES THIS THEN THIS WILL SHOW, OR IF TAGGED VIDEOS THEN THIS WILL SHOW, OR IF TAGGED LINKS THEN THIS WILL SHOW.
    Every 4th Post should be Styled Differently (I need the 4th post, 8th post, and 12th post to have 0 padding so I need to style them differently.)

    The problem I have is that I’m not sure how to put a counter in the posts to style the 4th posts differently. Also, the pagination gets messed between pages.

    Here’s the code for the counter that I think I have to use…

    <?php $counter=0;
    ...query_posts...if you need it...
    if (have_posts()) :
    while (have_posts()) : the_post(); ?>
    <?php $counter++; ?>
    <div class="post <?php if( $counter%4 == 0 ) { echo ' post_four'; ?>">
    ...the usual html/php for post title, content, postmetadata etc. ...
    </div> <!--end of .post -->
    
    <?php endwhile; endif; ?>

    I’m not sure where to put that though. Here’s a link to see it live, and here’s a link to see my whole index.php: http://wordpress.pastebin.com/e4NQJUxP

Viewing 1 replies (of 1 total)
  • vtxyzzy

    (@vtxyzzy)

    See this thread for some code to provide a different number of posts on the first page, but without the ‘featured’ post.

Viewing 1 replies (of 1 total)
  • The topic ‘Style Tagged Posts and Every 4th Post differently in index.php?’ is closed to new replies.