WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Want Post Excerpts* on Archive and Search Result Pages (4 posts)

  1. infavoroffuzz
    Member
    Posted 4 years ago #

    I want full posts on my blog in general, but only post excerpts on archive and search result pages. I cannot find "archives.php" or "search.php" in my index template; they must be named otherwise. I found one "php the_content", but when I change this to "php the_excerpt" it changes the entire blog.

    Below is my index. Please help!

    ------

    <?php get_header(); ?>
    
    <div id="content">
    
    <?php if(is_front_page()) { ?><?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Home-Top') ) : ?><?php endif; ?><?php } ?>
    
    <?php if(is_single() || is_page()) { ?><?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Column-Top') ) : ?><?php endif; ?><?php } ?>
    
    <?php if (have_posts()) :?>
    
    <?php $postCount=0; ?>
    
    <?php while (have_posts()) : the_post();?>
    
    <?php $postCount++;?>
    
    	<div class="entry entry-<?php echo $postCount ;?>">
    
    		<h2><a>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    		<div class="meta">
    		<?php edit_post_link('Edit', '', ''); ?>
    		<div class="meta-postedby">Posted <?php the_time('F jS, Y') ?> by <?php the_author() ?> <?php if(is_page()) { ?><!--nothing--><?php }else{ ?>and filed in <?php the_category(', ') ?><?php } ?> </div>
    		<div class="meta-tags"><?php the_tags( 'Tags: ', ', ', ''); ?></div>
    		<div class="meta-addcomment"><?php comments_popup_link('Add a Comment', '1 Comment', '% Comments', 'commentslink'); ?></div>
    		</div><!--end meta-->
    
    		<div class="the_content">
    		<?php if(is_front_page()) { ?><?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Post-Top-Right-Home') ) : ?><?php endif; ?><?php } ?>
    		<?php if(is_single() || is_page()) { ?><?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Post-Top-Right-Single') ) : ?><?php endif; ?><?php } ?>
    		<?php the_content('Continue Reading &raquo;'); ?>
    		<?php if(is_front_page()) { ?><?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Post-Bottom-Home') ) : ?><?php endif; ?> <?php } ?>
    		<?php if(is_single() || is_page()) { ?><?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Post-Bottom-Single') ) : ?><?php endif; ?> <?php } ?>
    		<?php if(is_page()) { ?>
    
    <ul>
      		<?php
    		global $id;
    		wp_list_pages("title_li=&child_of=$id"); ?>
    		</ul>
    		<?php } ?>
    
    		<div class="link_pages"><?php wp_link_pages(); ?></div>
    
    		</div><!--end the_content-->
    
    		<div class="comments">
    		<?php comments_template(); ?>
    		</div><!--end comments-->
    
    	</div><!--end entry-->
    
    <?php endwhile; ?>
    
    		<div id="prevnext">
    		<?php previous_posts_link('&laquo; Newer') ?> <?php next_posts_link('Older &raquo;') ?>
    		</div><!--end navigation-->
    
    <?php else : ?>
    
    	<div class="entry">
    		<h2>Not Found</h2>
    		<div class="the_content">
    		<p>Sorry we can't find what anything that matches your search.</p>
    		<p>You could try another search or browse our categories.</p>
    		<?php get_search_form(); ?>
    		</div><!--end the_content-->
    
    <ul><?php wp_list_categories('title_li=<h2>Categories</h2>'); ?></ul>
    	</div><!--end entry-->
    
    <?php endif; ?>
    
    </div><!--end content-->
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>

    ------

  2. Chris_K
    Member
    Posted 4 years ago #

    Copy index.php to archives.php and search.php.

    In each of the new files, replace
    <?php the_content('Continue Reading &raquo;'); ?>
    with
    <?php the_excerpt(); ?>

    More at http://codex.wordpress.org/Function_Reference/the_excerpt

  3. infavoroffuzz
    Member
    Posted 4 years ago #

    Thank you SO much, Chris!!

    It only worked if I saved as "archive.php" instead of the plural, but other than that, the fix was golden!

  4. Chris_K
    Member
    Posted 4 years ago #

    apologies. I've been mixing up archives and archive for a few years now :-)

Topic Closed

This topic has been closed to new replies.

About this Topic