Support » Fixing WordPress » Different Styling for alternate blog posts

  • Hi there,

    I’m using a heavily modified The Morning After theme (it is now essentially a custom theme).

    I am designing a static homepage that shows the latest posts listed at the bottom.

    I would like consecutive blog posts to be styled differently, i.e. the first title and excerpt floated left, the second floated right, the third floated left, etc.

    How do I go about doing this? My php knowhow is pretty limited – so be kind 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Thread Starter GuruMag

    (@gurumag)

    Thanks, that looks just the right sort of thing. How would I incorporate this into the WordPress loop?

    My loop looks like this (to display category, title, excerpt and featured image:

    <div id="content">
    <?php $temp_query = $wp_query; ?>
    
    <?php query_posts('showposts=8'); ?>
    
    <?php while (have_posts()) : the_post(); ?>
    
    	<div class="post" id="post-<?php the_ID(); ?>">
    
    <div class="header-content" >
    
    <?php
            $id = get_the_ID();
            $cats = get_the_category();
        ?>
    
    <a href="<?php echo get_category_link($cats[0]->cat_ID); ?>">
        <?php echo $cats[0]->name; ?>
    
    <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3>
    
    <?php the_excerpt(); ?>
    </div>
    
    <div class="featured image">
    <?php the_post_thumbnail('front-page-post-thumbnail'); ?>
    </div>
    
    	</div>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Different Styling for alternate blog posts’ is closed to new replies.