How to display only an excerpt of the content with custom post types?

<?php
/*
Template Name: second
*/
?>


<?php get_header(); ?>


<?php query_posts(array('post_type'=>'event')); ?>
    <?php if(have_posts()) while(have_posts()) : the_post(); ?>
    <div id="post-<?php the_ID(); ?>" class="entry">
        <div class="thumbnail"><?php the_post_thumbnail('full'); ?></div>
        <h1 class="title"><?php the_title(); ?></h1>
        <div class="content page">
            <?php the_content(); ?>
            <?php wp_link_pages(array('before' => '<div class="page-link">'.__('Pages', 'cpotheme').':', 'after' => '</div>')); ?>
        </div>
    </div>
    <?php endwhile; ?>


<?php get_sidebar(); ?>
<?php get_footer(); ?>

The page acts like an index.php What should I amend in order to make the title as the link to the full page and make display only an excerpt of the content?

3 Answers
3

You only need two small changes (1st and 3rd lines), though I also took the liberty of tweaking the classes on the div to what seemed more appropriate:

<h1 class="title"><a href="https://wordpress.stackexchange.com/questions/67750/<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<div class="excerpt event">
   <?php the_excerpt(); ?>
   <?php wp_link_pages(array('before' => '<div class="page-link">'.__('Pages', 'cpotheme').':', 'after' => '</div>')); ?>
</div>

Leave a Comment