More Paragraphs: A “More” Plugin for WordPress
Publicado por Aníbal Rojas 26 Julio 2005 en PHP.This is a WordPress plugin that automatically inserts a <!–more–> tag after a user configurable number of paragraphs.
It is based on the Evermore plugin writen by Bennett, which I initially tried to use. The two main differences from Evermore are:
- The number of paragraphs to insert the <!–more–> tag are configurable in the Options menu, while Evermore default to one paragraph.
- And this plugins is written to handle safely content processed by WYSIWYG Plugin for WordPress from MudBomb, or pasted from a web page or other highly formatted source.
More Paragraphs is designed to handle all the XHTML block tags, searching the content of the post for a safe place to insert the <!–more–> tag without breaking everything.
In the meanwhile the plugin version 1.0-b1 can be downloaded here more-paragraphs.php. This version is considered experimental, and I would not recommend installing it in a “production” blog, while I would greatly thank your tests on an experimental enviroment.
Installation Instructions:
- Rename the file more-paragraphs.php.txt to more-paragraphs.php, stripping the final “.txt”
- Copy the file into the wp-content/plugins folder.
- Got to the Plugins menu of WordPress and activate it.
- Optionally go to Options menu, select the “More Paragraphs” tab and specify the number of paragraphs to insert the <!–more–> the default value is 3.
Requirements:
- WordPress 1.5.x
Current Restrictions:
- It will ignore a existent <!–more–> tag.
Future Development:
- Consider existent <!–more–> tag, if it is located inside the range of paragraphs configured by the user, the original content will not be modified.
- Allow the author specify the number of paragraphs for a selected post, using custom fields. Optionally verify if the author value is less or equal the number in the configuration. This feature would be handy for blogs with multiple authors.
- If it is impossible to add the <!–more–> tag due to the block structure of the post, clean the block tags and work with the “clean” text trying to find a fit, while keeping inline formatting.
I found this page after looking at Evermore and Less plugins, by Bennett McElwee. I like More-Paragraph’s functionality, particularly the user-defined number of paragraphs before the break, as well as its respect for XHTML tags.
However, I have a problem with two of my posts, which include a photograph and markup from the Flickr.com webservice. Your plugin seems to cut the markup at an awkward point, so that a “ element displays to the user.
Here is the offending code:
`
my baby
Originally uploaded by tqn69.
Saturday, minding Sophie alone all day while Luna works. So far Sophie has consumed three disposable diapers and 10 ounces of breastmilk. This being a [Seafair weekend](http://seattlepi.nwsource.com/local/234604_seafair30.html “It’s time again for Seafair…”), formations of [Blue Angels](http://www.blueangels.navy.mil/flashindex.html) would thunder overhead, causing me to leave the wriggly baby—but only for a moment!—to rush out to the deck for a glimpse. Later the buzz of
hydroplanes came from the lakebiplanes cut through the air. Blecchh.The beautiful light streaming in from the west was impossible to pass up. I posed Sophie against a green blanket on the floor. *Snap.* Our curtains diffused the afternoon light. *Snap, snap.*`
I’d be happy if it were possible to handle this case. Because I really like this plugin you have written!
Hmm, the code didn’t show up. How about this:
my baby
Originally uploaded by tqn69.
Saturday, minding Sophie alone all day while Luna works. So far Sophie has consumed three disposable diapers and 10 ounces of breastmilk. This being a [Seafair weekend](http://seattlepi.nwsource.com/local/234604_seafair30.html “It’s time again for Seafair…”), formations of [Blue Angels](http://www.blueangels.navy.mil/flashindex.html) would thunder overhead, causing me to leave the wriggly baby—but only for a moment!—to rush out to the deck for a glimpse. Later the buzz of
hydroplanes came from the lakebiplanes cut through the air. Blecchh.Thanks a lot for your feedback Tri, I am giving you my email address so you can send me the offending code attached in a .txt file.
Hola!
Me encanta tu plugin, está de puta madre. Hacía mucho que busaba uno asi :)
Un abrazode un hermano peruano.
Alejandro
Anibal,
I love this plugin. I’ve only got one problem. If I have paragpraphs inside of
oh in the comment above I meant “inside of blockquote” but put it in brackets.
Weird behavior!!
Your plug in appears to work fine as far as trimming the posts as indicated, but on one of my posts every sentence is now been underlined!!!
How did you do that? It must be a bug in some code for html or something.
Hi! Your plugin has worked great fo us except for a couple of times when for no reason when posting we got the following error:
Fatal Error: Allowed memory size 0f 8388608 bytes exhausted (tried to allocate 191 bytes) in var/www/html/wp-content/plugins/more-paragraphs.php on line 108.
Any idea why we’re running out of memory with such small posts?
for your info: lines 107 to 110
$offset = strlen($matched)+$matched_at;
$continue = preg_match($lcomp_regexp, $post_content, $match, PREG_OFFSET_CAPTURE, $offset);
}
return $post_content;
also got this error when trying to post a comment:
This weblog is protected by WP-Morph. This is to prevent comment spam. You have to have JavaScript enhabled in order to post comments here. Sorry for the inconvenience.
I do have JS enabled! :)
Thanks a lot for you comment, would you please send me the posts that generated the problem. I think I am going to rewrite completly this plugin, with another approach.
sure, could you maybe send me your email address - one of the posts is rather long for the comment box :)
Sure, you can mail me to the address listed in this page:
http://www.lacaraoscura.com/author/ard/
Thanks for your help.
Hi,
I wish to translate the word ‘more’ to portuguese, so it shows “leia mais” instead. How i do that?
thanks and great plugin :)
Nice plugin–I haven’t implemented it yet because it isn’t quite what I need though. I am importing RSS feeds using FeedWordPress, and I would like those to be shortened, but not all of my posts. FeedWordPress creates a user for each feed, so I would like to be able to set a post limit length on SOME users but not all. Another method would be to shorten based on category. Are you planning on developing this plugin further?
Hello,
Can’t download your plugin, could you check it? Thanks.