Make WordPress Core

Opened 4 years ago

Last modified 2 years ago

#56691 new enhancement

Function suggestion: get_excerpt_length()

Reported by: tremidkhar Owned by:
Priority: normal Milestone: Awaiting Review
Component: General Version:
Severity: normal Keywords: has-patch
Cc: Focuses:

Description

Currently, there is no way we can get the excerpt length whether the default or the filtered value.

This will be useful when developers in some way need to get the post excerpt length.

For now, developers can use something like the following to match the excerpt length with the of the site.

<?php
$excerpt_length = apply_filters( 'excerpt_length', 40 );

With the new function, developers don't have to remember to add the filter, they can just call the function and get the excerpt length that matches the rest of the site.

<?php
$excerpt_length = get_excerpt_length();

Change History (3)

This ticket was mentioned in ​PR #3367 on ​WordPress/wordpress-develop by ​TremiDkhar.


4 years ago
#1

  • Keywords has-patch added

#2 @tremidkhar
2 years ago

  • Summary Introduce a function get excerpt length → Function suggestion: get_excerpt_length()

#3 @tremidkhar
2 years ago

Hello @SergeyBiryukov,

Can we have your thoughts on this, please?

Note: See TracTickets for help on using tickets.