• Resolved micdt

    (@micdt)


    I’d prefer if Ryu showed just the excerpt of a post on the frontpage using the excerpt-field from each post – not (!) the more-tag.
    I know this requires a child-theme. So if someone could point me the way which file(s) to change and how.
    Thanks in advance

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi @micdt,

    It is possible to achieve what you’re after but, as you’ve noted, will require you to experiment a little with the theme’s HTML/PHP and to set up a child theme.

    In case you’re unsure, the following guides provide a good introduction to child themes, including steps to set one up:

    After you have completed that step, copy the parent’s content.php file to your child theme’s directory and then open it in your favourite text/code editor.

    Locate the following code in that file:

    <?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'ryu' ) ); ?>

    For what you’d like to achieve, you will need to replace the the_content() function with the the_excerpt function:

    <?php the_excerpt( __( 'Continue reading <span class="meta-nav">→</span>', 'ryu' ) ); ?>

    Let me know how that goes!

    Thread Starter micdt

    (@micdt)

    Good morning Siobhan,

    wohoo, that worked ??
    Thanks a lot.

    I just wonder why this did not work before, when I tried replacing the_content by the_excerpt on the original theme. Might have been a cache-issue though…

    Michael

    Hi Michael,

    I’m glad that worked out!

    I’m not sure why it didn’t work originally, but I’m glad it does now. ?? If any other trouble does come up then please feel free to start another thread here and we can troubleshoot.

    Thread Starter micdt

    (@micdt)

    Hi Siobhan,

    I was so happy that I saw the excerpt on the frontpage that I did not notice at first that I see *just* the excerpt on the single page as well :/

    So, one problem fixed, created another…

    Michael

    I’m so sorry for that oversight on my part, Michael! I should have spotted that mistake in my own testing.

    To fix, we’re going to look at the following part of the code as a whole:

    <?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 clear">
    	<?php the_excerpt( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'ryu' ) ); ?>
    	<?php
    		wp_link_pages( array(
    			'before'      => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'ryu' ) . '</span>',
    			'after'       => '</div>',
    			'link_before' => '<span>',
    			'link_after'  => '</span>',
    		) );
    	?>
    </div><!-- .entry-content -->
    <?php endif; ?>

    The above code is using a conditional tag to detect when a page is a search page and using the the_excerpt() to display an excerpt in that case. It is using the the_content() function in all other cases.

    To switch this around, we can use the is_single() conditional tag with the_content() and display the_excerpt() in all other cases:

    <?php if ( is_single() ) : // Only display full content on single posts ?>
    <div class="entry-content clear">
    	<?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'ryu' ) ); ?>
    	<?php
    		wp_link_pages( array(
    			'before'      => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'ryu' ) . '</span>',
    			'after'       => '</div>',
    			'link_before' => '<span>',
    			'link_after'  => '</span>',
    		) );
    	?>
    </div><!-- .entry-content -->
    <?php else : ?>
    <div class="entry-summary">
    	<?php the_excerpt(); ?>
    </div><!-- .entry-summary -->
    <?php endif; ?>

    Let me know how you get on with that above! I’ll be happy to help if questions come up.

    Thread Starter micdt

    (@micdt)

    Hey Siobhan,

    after some days of distro-hopping I finally managed to test the proposed changes today and everything is wonderfully, perfectly, magically fine ??

    Thanks a lot!
    Michael

    ps. You can see the result – not all ready yet, but I am getting there – here.

    I’m happy to hear that, Michael. The site’s looking great!

    We’re right here if any more questions come up while getting it set up, too. ??

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Excerpt vs. Content’ is closed to new replies.