• I have a WordPress blog and recently just realized it is showing the entire article. How can I get the blog to only show an excerpt with a read the full article button at the bottom? Which template will have I edit and which code will I have to add?

Viewing 8 replies - 1 through 8 (of 8 total)
  • hi

    start with index.php

    find the_content(' ....... ')
    replace it with the_excerpt()

    you may want to do the same in
    category.php and archive.php

    Thread Starter mayiced

    (@mayiced)

    Alright so I changed the code in
    index.php from the_content(‘…….’)

    to

    <?php the_excerpt(‘Read the rest of this entry »’); ?>

    It worked but the excerpt post is not showing the “Read the rest of this entry” How can I get the “Read the rest of this entry to show under the excerpt? Looks like I don’t have the category.php but two archive.php files. One is archive.php the other archives.php I did the change in the archives.php but did not see any change.

    You can use the more button when writing a post or find yourself an excerpt plugin such as Excerpt Editor.

    Thread Starter mayiced

    (@mayiced)

    Can you tell me more about using the more button when adding a new post? Do I just copy the code into the html view or is there a hidden trick to this?

    In the visual editor the button simply says more in the html editor it is an icon. Just hover over the buttons and you’ll find it.

    [edit] there you go:
    deanlee.cn/wp-content/uploads/2008/10/image6.png

    This is not wrong
    <?php the_excerpt('Read the rest of this entry »'); ?>
    but has no effect – the excerpt is only the_excerpt();

    You can use the More tag if you prefer as Gangleri is suggesting – its a matter of preference.

    If you want to use the_excerpt and have a read more link at the end, here is some code to put in the theme file functions.php that will do so:

    function excerpt_ellipse($text) {
       return str_replace('[...]', ' <a href="'.get_permalink().'">Read more...</a>', $text); }
    add_filter('the_excerpt', 'excerpt_ellipse');

    Thread Starter mayiced

    (@mayiced)

    I have done as suggested above but it is still not working. Below is the code from my functions.php Anyone see anything different that I should change?

    <?php
    if ( function_exists('register_sidebar') )
        register_sidebar(array(
        	'name' => 'Sidebar left',
            'before_widget' => '<li id="%1$s" class="widget %2$s">',
            'after_widget' => '</li>',
            'before_title' => '<h3 class="widgettitle">',
            'after_title' => '</h3>',
        ));
        register_sidebar(array(
        	'name' => 'Sidebar right',
            'before_widget' => '<li id="%1$s" class="widget %2$s">',
            'after_widget' => '</li>',
            'before_title' => '<h3 class="widgettitle">',
            'after_title' => '</h3>',
        ));
    
    function excerpt_ellipse($text) {
       return str_replace('[...]', ' <a href="'.get_permalink().'">Read more...</a>', $text); }
    add_filter('the_excerpt', 'excerpt_ellipse');
    ?>

    the code I posted only works with the_excerpt() – if you are using the more tag and the_content() it won’t do a thing.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Show Excerpt’ is closed to new replies.