WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Unable to get manual excerpts to display how I wish... (4 posts)

  1. pinkbeats
    Member
    Posted 4 years ago #

    Morning folks,

    I have been googling online, searched here in forums and have experimented with a couple of excerpts plugins but haven't been able to find something that works how I wish it to. What I would like to accomplish is:

    1. for posts to display manual excerpts where I have written one
    2. to display a thumbnail image in the manual excerpt (that I can position using CSS)
    3. if there isn't a manual excerpt, to display the whole post instead

    Currently, if I type a couple of lines of text into the Excerpt box, the theme that I'm using on my blog, doesn't display it. The following two posts have a manual excerpt - here and here.

    Ideally, the code would check to see if there was a manual excerpt - if there was, to display the excerpt otherwise the post in it's entirety. Most of my posts have use the Audio Player plugin and have it embedded at the top before any text and this can lead to some ugly automatic excerpts displays.

    For example, the code within the index.php file of my theme reads <?php the_content('Read the rest of this entry &raquo;'); ?> which, after reading a bit more about it in the Template Tags in the Codex, if I replace it with <?php the_excerpt('Read the rest of this entry &raquo;'); ?> does then show any manual excerpts but then displays automatic excerpts for all other posts which don't have any as this image illustrates.

    I found and read an articles called "How To Display Manual Excerpts On Your Home Page" (see here) and "How To Create Conditional “Read More” Links For Manual Excerpts" (see here) which seemed to have a solution (except for displaying a thumbnail) but it doesn't seem to work and I'm wondering if I've implemented the code correctly.

    So basically, I would like to use manual excerpt function within WordPress - to display one if I've written something (preferably with a thumbnail image) otherwise to just display the whole post. I'm going to experiment a little more but any help or suggestions appreciated. Thanks.

  2. pinkbeats
    Member
    Posted 4 years ago #

    Update - upon re-reading How To Display Manual Excerpts On Your Home Page - I replaced:
    <?php the_content('Read the rest of this entry &raquo;'); ?>

    which was in the index.php file for the theme I'm using, with:

    <?php
       if (function_exists('has_excerpt') && has_excerpt()) the_excerpt();
       else the_content('Read on...');
    ?>

    and the results are good - the two posts where I'd written manual excerpts, display them, the posts that don't are displayed in full.

    I still would like a 'Read more...' link to display on the posts that have manual excerpts (but not on those that don't) and to be able to insert a thumbnail image to float to the left of the excerpt text. I'm quite happy to create and upload the thumbnails rather than force the browser to re-size them, if that makes any difference?

  3. pinkbeats
    Member
    Posted 4 years ago #

    Have figured out how to add a 'Read more...' link to the posts which have excerpts...full code you need to use from both Chad's articles is:

    <?php
       if (function_exists('has_excerpt') && has_excerpt()) the_excerpt();
       else the_content('Read on...');
    ?>
    <?php
     if (function_exists('has_excerpt') && has_excerpt()) { ?>
    <a href="<?php the_permalink() ?>" title="Continue Reading <?php the_title_attribute(); ?>...">Read the rest of <?php the_title(); ?> &raquo;</a>
    <?php  } ?>

    Right - just need to work out how to insert a thumbnail and how to use CSS to position the 'Read more...' link exactly where I want it.

  4. pinkbeats
    Member
    Posted 4 years ago #

    This topic is resolved - will post another thread if I can't work out how to use the WordPress thumbnail images in my excerpts by using the custom fields.

Topic Closed

This topic has been closed to new replies.

About this Topic