Allow the_excerpt() to accept arguments like the_content()
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
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,
These two parameters for
the_excerpt() function would be great!
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.
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 ?>
<?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:
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!
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.
RSS feed for this topic
You must log in to post.