Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am using two themes (full and desktop), so I am trying to get them to behave in the similarly.

The archive.php for the mobile theme is doing what I want, which is to just show the title and post excerpt. I think this is the bit of code that does that:

<?php while ( have_posts() ) : the_post(); ?>
    <?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>

The archive.php for the desktop site is showing whole posts, where I want it to only show the excerpt, as well as featured images.

<div <?php post_class() ?>>
   <span class="postmetadata"><?php the_category(' / '); ?> &mdash; <?php edit_post_link( __( 'Edit', 'mythemename' ), '', ' &mdash; '); ?>  <?php comments_popup_link( __( 'No Comments', 'mythemename' ), '1 Comment', '% Comments' ); ?></span><br/>
      <small><span class="datef"><?php the_time('d'); ?></span><br /><?php the_time('M \'y'); ?> <!-- by <?php the_author() ?> --></small>
   <h2><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php _e( 'Permanent link to ', 'mythemename' ); ?><?php  the_title_attribute(); ?>"><?php the_title(); ?></a></h2>

   <div class="entry">
      <?php the_content( '<em>Continue reading &rarr;</em>' ); ?>
   </div>
   <div class="clearfix"></div>             
</div>

I don't know it does not use a php function to do all that. How could I replace that with something that will show all the same stuff, but only the post excerpt, with featured image?

share|improve this question
add comment

1 Answer

To replace the full content with the excerpt, change

<?php the_content( '<em>Continue reading &rarr;</em>' ); ?>

To

<?php the_excerpt(); ?>

To display the featured image use this:

<?php the_post_thumbnail( 'single-post-thumbnail' ); ?>

Note: Make sure you have this next snippet somewhere in your theme's functions.php file

//add theme support for post thumbnails
add_theme_support( 'post-thumbnails' );
share|improve this answer
    
Thanks, but could you edit your answer to include how to add the 'Continue reading' links for excerpts? Also, posts without excerpts are truncated with [...] at the end, but there is no link. –  paradroid Oct 17 '12 at 23:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.