WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Can't figure out where to put post excerpt code! (6 posts)

  1. CSSLover
    Member
    Posted 1 year ago #

    I have been searching the help topics (like this one), and cannot find the answer to customizing my particular theme to show post excerpts on my home page. I am using the Toolbox theme, and do not know where to put <?php the_excerpt() ?> in its code.

    Here is the Loop code from my index.php:

    <?php if ( have_posts() ) : ?>
    
    				<?php toolbox_content_nav( 'nav-above' ); ?>
    
    				<?php /* Start the Loop */ ?>
    				<?php while ( have_posts() ) : the_post(); ?>
    
    					<?php
    						/* Include the Post-Format-specific template for the content.
    						 * If you want to overload this in a child theme then include a file
    						 * called content-___.php (where ___ is the Post Format name) and that will be used instead.
    						 */
    						get_template_part( 'content', get_post_format() );
    					?>
    
    				<?php endwhile; ?>

    Could someone please help me out? I am still an amateur at PHP and don't quite understand it all yet!

    Here's the link to the website I am building:
    http://www.thegarmsfamily.com

  2. Rev. Voodoo
    Volunteer Moderator
    Posted 1 year ago #

    that index.php uses:

    get_template_part( 'content', get_post_format() );

    which offloads to a template based on selected post format, so you would be looking for any file that starts with content such as:

    content.php
    content-status.php
    content-link.php
    content-aside.php

    I haven't seen the theme to be sure, but chances are content.php would be the main one to edit, it looks like that would be the catch all for standard post formats (normal posts)

  3. CSSLover
    Member
    Posted 1 year ago #

    Thanks - I'll check for those!

  4. CSSLover
    Member
    Posted 1 year ago #

    In my content.php page, this code follows:

    <?php if ( is_search() ) : // Only display Excerpts for Search ?>
    	<div class="entry-summary">
    		<?php the_excerpt(); ?>
    	</div><!-- .entry-summary -->
    	<?php else : ?>
    	<div class="entry-content">
    		<?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'toolbox' ) ); ?>
    		<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'toolbox' ), 'after' => '</div>' ) ); ?>
    	</div><!-- .entry-content -->

    I assume I remove/edit the code which says...

    <?php if ( is_search() ) : // Only display Excerpts for Search ?>

    ...right? Or what do I need to edit? Thank you!

  5. Doodlebee
    Member
    Posted 1 year ago #

    If you just want excerpts to show up on your home page, look for this:

    <?php if ( is_search() ) : // Only display Excerpts for Search ?>
    	<div class="entry-summary">
    		<?php the_excerpt(); ?>
    	</div><!-- .entry-summary -->
    	<?php else : ?>

    and edit it to this:

    <?php if ( is_search() || is_home() || is_front_page() ) : // Only display Excerpts for Search and home page ?>
    	<div class="entry-summary">
    		<?php the_excerpt(); ?>
    	</div><!-- .entry-summary -->
    	<?php else : ?>
  6. CSSLover
    Member
    Posted 1 year ago #

    That WORKED! :)

    Thank you SO much for helping me out, Shelly and Rev. Voodoo! I very much appreciate it.

Topic Closed

This topic has been closed to new replies.

About this Topic