0

Working on a client site that displays a blog excerpt on the blog page (which shows 5 posts per page) and the main home page (which shows the latest 3 blog posts).

The trouble is I want different layouts for the excerpt. The client will always have an image/video in each post, so would like to grab this and display on the excerpt.

Here is an image of the two layouts I am trying to achieve... https://dl.dropboxusercontent.com/u/94593656/excerpts.jpg

The right layout for the blog page is fairly simple. I bring the image/video content into the excerpt by using the Advanced Excerpt plugin, however I am not sure how to achieve the left layout for the home page. Notice how the image/video and text is separated, so I cannot just call the_excerpt.

Is there a way to bring the image/video and text in separately? What would be the best way to do this?

To give you an idea, this is what I currently have for the markup for the home layout but the image is not yet dynamic, and the excerpt text is not there yet...

<?php $my_query = new WP_Query('showposts=1');
          while ($my_query->have_posts()) : $my_query->the_post(); ?>
    <div class="aspect1">
      <a href="#"><img class="block" src="<?php bloginfo('template_url'); ?>/assets/images/pic1.jpg" alt=""></a>
    </div>
    <div class="feat-text">

      <time datetime="<?php the_time('Y-m-d') ?>"><?php the_date('jS F Y') ?></time>
      <h3 class="h2"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>

      <a href="<?php the_permalink(); ?>" class="viewp">View post &rarr;</a>

    </div>
    <?php endwhile; ?>

Any help would be greatly appreciated

1

The Advanced Excerpt plugin offers the_advanced_excerpt() for customisation, take a look here.

The layouts you want to achieve are basically depending on your css, you have to declare the rules for them depending on the body of each template (home and blog). For adding body classes take a look at the codex, if your theme not allready has this implemented.

  • Thank you so much. Did not know about the_advanced_excerpt. Exactly what I needed – Adam Jun 2 '13 at 22:20

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.