WordPress.org

Ready to get started?Download WordPress

Ideas

Allow the_excerpt() to accept arguments like the_content()

  1. dcavins
    Member

    12345

    I've been using excerpts quite a bit on a new project which is more CMS-y, and they've not been as easy to use as I'd like. I'd like for the_excerpt() to accept parameters, parallel to how the_content() works.

    As an alternative to adding a "read more" tag via functions, one could specify the_excerpt('Read more...'). Instead of hooking to the excerpt_length action, one could specify the length directly, like the_excerpt('Read more...', 40).

    These two arguments would have come in handy for me, as I'm using a variety of lengths and styles of excerpts (sometimes on the same page, like a magazine-style front page).

    Thanks for listening,

    -David

    Posted: 1 year ago #
  2. Ziv
    Member

    12345

    These two parameters for the_excerpt() function would be great!

    Posted: 1 year ago #
  3. Ashley8erry
    Member

    Hi dcavins,

    I have learned an interesting thing from your post.

    I am curious to know that
    1) either this the_excerpt() works in php files individually created for another site?
    2) could you give an example that how the_excerpt() simply apply in the coding of php file.

    Eagerly awaiting the reply.

    Posted: 1 year ago #
  4. dcavins
    Member

    12345

    A good example of the using the_excerpt() is in the content.php file within the theme twenty twelve:

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

    Read the section the_excerpt vs the_content here for an understanding of why you might like to use the excerpt from time to time:
    http://codex.wordpress.org/Function_Reference/the_excerpt

    Posted: 1 year ago #
  5. alajoann
    Member

    On several occasions, I have copied/pasted a .php code snippet that limits the number of words in an excerpt. (Although limiting the number of characters would be better.) I think a lot of people would appreciate being able to do this more simply.

    Another related point:

    I have not figured out how to remove content headings from the excerpt. (Though the HTML markup is removed!)

    I try to write like a journalist - with something meaningful in the first sentence that is quick and easy to absorb. Because I use a heading at the top of the content, I always need to manually create an excerpt - or else the heading is included in the excerpt!

    Posted: 11 months ago #
  6. ConcertPass
    Member

    Hello dcavins,
    one year has passed since your suggestion and it is still a great idea; the two parameters for the_excerpt() would add flexibility to the function.
    Regards

    Posted: 21 hours ago #

RSS feed for this topic

Reply

You must log in to post.

  • Rating

    12345
    14 Votes
  • Status

    This idea is under consideration

Tags