↑ Return to Y10 Excerpts Meta

PRIV Y12 Make Excerpts Longer

Page no: Y12




This function allows to lengthen the excerpt to … characters.




Explode a paragraph into sentences in PHP

I have been using


to split a paragraph into sentences. However this doen’t cover sentences that have been concluded with different punctuation such as ! ? : ;

Is there a way of using an array as a delimiter instead of a single character? Alternativly is there another neat way of splitting using various punctuation?

I tried

explode(("." || "?" || "!"),$mystring)

hopefully but it didn’t work…

You can use preg_split() combined with a PCRE lookahead condition to split the string after each occurance of ., ;, :, ?, !, .. while keeping the actual punctuation intact:



- Click to enlarge

This code works, but can’t help in our situation, because it explode the paragraph on sentences. We need to cut it on symbols. This is not a real problem, because using it we have to count every single sentences and then to decide how much sentences to add into the excerpt. This is a very slow process, which is a memory consuming. On our syndication tools and many posts can lead to memory issues and a lot of time for loading the page. We always need the best and fast problem. So we made a custom Regex code.



. - Click to enlarge


Empty Excerpts

Prio: 22

Status: In Trello

problem1: The generate excerpt function generates empty excerpts.

problem2: The function cannot be executed multiple times. “No posts found or function already applied.” But it should be possible; for example when you change the post.

Example Post

Select: Acemaxx Sept 2016 to End Date

 Avoid that excerpts are empty. The function only copies the beginning of the text. Hence it must be possible to execute it multiple times.


problemThe first problem is fixed. The second one is done, too. But it will work only if the new excerpt is different than the old one.


Executing Function Multiple Times
Executing Function Multiple Times

- Click to enlarge


Line Break

Prio: 15

Status: In Trello

problem When there is a line break, then the excerpt is put directly after the previous sentence without a space or a line break).

The excerpts does not use line breaks, hence we must use a space.


Recognize end of lines and add a space into the excerpt are done by wordpress, so we can’t change it.

Version of changes 3.6, implemented on all.



New Exceprt Beginning
New Exceprt Beginning

- Click to enlarge

Wrong Statistics of Execution

Prio: 14

After Execute All, the program says “We found 238 and generated longer excerpts for 92”
Why did it not execute for all?

Category: Bankiervereingung on Ecoblogs.ch

Possibly the text was not long enough. Hence we need the execution message: “146 posts had only a short text, so we could not generate longer excerpts”.

Longer Excerpt Function
Longer Excerpt Function

The new text for longer excerpt function - Click to enlarge

The new text for longer excerpt function


Results after run Make Excerpts Longer Function.





See more for sYndication Tools