[wp-trac] [WordPress Trac] #39921: the_excerpt needs additional parameters to control teaser length and visibility of 'read more' link

WordPress Trac noreply at wordpress.org
Mon Feb 20 16:33:03 UTC 2017


#39921: the_excerpt needs additional parameters to control teaser length and
visibility of 'read more' link
------------------------------+-----------------------------
 Reporter:  subrataemfluence  |      Owner:
     Type:  enhancement       |     Status:  new
 Priority:  normal            |  Milestone:  Awaiting Review
Component:  Customize         |    Version:  4.7.2
 Severity:  normal            |   Keywords:
  Focuses:  performance       |
------------------------------+-----------------------------
 Function `the_excerpts()` need additional parameters to control teaser
 length and visibility of "read more" link. Applying filters in
 `functions.php` in order to customise 'read more' link or teaser length
 make it pretty generic.

 If the function can look like this:
 {{{the_excerpt($length, $moreLink = true)}}} and we can pass these values
 as and when required the function would become more useful!

 Where this could be useful? Here is an example (screenshot attached):

 In my site, users can post their trip report from front end via a custom
 post type. Admin publishes a post and decides whether or not to make the
 post visible on the site immediately (by 'Scheduling a post).

 There is a page where all "Published" posts are listed (scheduled "today")
 and a right sidebar to list 10 posts which are "scheduled" for a later
 date (Upcoming Stories).

 Such posts are listed with their title and excerpt but there would be no
 link for users to view the details. The posts are listed under Upcoming
 for better indexing and encouraging people to come back to the site more
 often to read new stories.

 The requirement is in under Upcoming Stories I want to put say 20 words
 without a `read more` link whereas the list (on the same page) in the
 content area would have bigger teaser (say 50 words) along with 'read
 more` link.

 The sidebar for Upcoming Stories is a custom plugin and placed inside a
 wizard while the main content is using a template page.

 My intention is to do something like this:

 In template code I would write:
 {{{the_excerpt(50)}}}

 and inside the plugin code I would wish to write:
 {{{the_excerpt(20, false)}}}

 I can hide `read more` link via CSS but it will not stop the URL from
 rendering. It will still be visible in page view source. Any scraping
 script would be able to find the these links easily!

 NB: In the screenshot, I have made `read more` link hidden in sidebar
 using CSS to explain what I am trying to say. The main content area list
 however displays the link. It would be great if this could be made using
 server side scripting like I mentioned above by adding two additional
 parameters in the function.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/39921>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list