[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
Tue Feb 21 06:42:50 UTC 2017


#39921: the_excerpt needs additional parameters to control teaser length and
visibility of 'read more' link
-------------------------------+------------------------------
 Reporter:  subrataemfluence   |       Owner:
     Type:  enhancement        |      Status:  reopened
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Posts, Post Types  |     Version:  4.7.2
 Severity:  normal             |  Resolution:
 Keywords:  close              |     Focuses:  template
-------------------------------+------------------------------

Comment (by grapplerulrich):

 {{{#!php
 <?php
 add_filter( 'excerpt_length', function( $number ) {
         if ( is_main_query() } {
                 $number =  50;
         } else {
                 $number = 20;
         }
         return $number;
 } );
 }}}

 There is whole list of conditional tags.
 https://codex.wordpress.org/Conditional_Tags

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


More information about the wp-trac mailing list