Plugins
Limit-Post Add-On
Limit-Post is one of the better WordPress post content limiters we have come across, both in terms of usability and size. Developed by labitacora.net Limit-Post provides excellent control over the post character-length and even adds the ability to create “read more …” link with a single line of code.
From labitacora.net: “We have developed a plugin for WordPress in order to control the maximum amount of characters displayed for an entry on the main page. If the set limit is surpassed a link to a page with the whole content will appear and the text on the entry will be chopped to that amount of characters, otherwise the content will be show[n] unchanged.”
It came to our attention not long ago that we needed to make use of the WordPress tag; get_the_content. For those unfamiliar, WordPress supplies two methods of displaying the post content through php;
Option#1: the_content(); – The more familiar method of displaying the post content
Option #2: get_the_content(); – The less familiar content tag which strips all html tags
Option #2 is useful for listing articles or news without interruption of paragraph breaks, block-quotes or links which can easily disrupt a strict layout. Not wanting to reinvent the wheel, we wrote a short addition to the Limit-Post plugin giving it the added feature of the get_the_content(); tag.
In the example below, the post content is displayed with all html stripped out, 320 characters in length and a continue link of “read more…”. For further instructions on the Limit-Post options please visit labitacora.net. Limit-Post is a very resilient plugin having remained functional since it’s inception in 2005 during the WordPress 1.5 era. It continues to function perfectly with WordPress 2.7.1.
Please note that because all html is stripped, it will be necessary to add paragraph tags around the content.
Example
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <?php the_title(); ?> <p><?php get_the_content_limit(320, 'read more...'); ?></p> <?php endwhile; endif; ?>
Installation
- Download the plugin and expand it.
- Copy the limitpost-addon folder into your plugins folder ( wp-content/plugins ).
- Log-in to the WordPress administration panel and visit the Plugins page.
- Locate the Limit Post plugin and click on the activate link.
- Replace the_content(); with the_content_limit(200, "continue..."); or
- Replace the_content(); with get_the_content_limit(200, "continue...");
92 Comments
Trackbacks
- How To limit the displayed text length on your Homepage - WordPress Plugin | MindPrompter.com
- Limit-Post Add-On | Doc4 | WpMash - WordPress News
- wp-popular.com » Blog Archive » Limit-Post Add-On | Doc4
- [ Plugin ] Limit-Post Add-On - WordPress Tavern Forum
- [ Plugin ] Limit-Post Add-On - WordPress Forums
Rob,
This plugin was not written by us, we simply included a few additional lines of code. Rather than steal the credit from the proper source it is expected that a user would visit labitacora.net for the full documentation on using the “Limit Post” plugin.
Man, you def need better documentation…
Dawn,
What you’re looking for is a WordPress loop calling a page. The code below is working under the assumption there is or will be additional loops on the same page:
Thanks for the speedy reply! I’m using the jQuery Easy Accordian (same one here: http://www.madeincima.eu/samples/jquery/easyAccordion/). It’s basically just content within tags in the slider panels, and I’m able to display the full content of a page via the normal WordPress syntax, but am not sure how to get it done with Limit-Post..
Dawn,
What slider are you using?
Hi! This is a really useful plug-in, and I’ve successfully implemented it for displaying my recent posts summary on my website’s home page. I’m kinda lost now though – I want to display limited content from a page into a slider I have on my homepage. Is this possible? I’m a noob at WP so do pardon me if the solution is really straightforward!
What I have now in my slider div:
<?php $page_id = 81; $page_data = get_page( $page_id ); $content = apply_filters('get_the_content_limit',$page_data->post_content); echo $content; ?>And.. it displays nothing.
Appreciate any help if you could! TIA!
Maurintius,
Every WordPress site is created differently, some have the loop built into pages and as you can see Twenty Ten has it’s own loop file. Basically, do a search for “the_content” and replace it with the new code. For example in the case of Twenty Ten: loop.php: Line 122:
Ohgfh,
Please take note that this is an “add-on” to another plugin not created by this company, hence the lack of instructions. If you don’t want to ask for assistance then please take a moment and read the post.
I’m using the default theme of WordPress “Twenty Ten” but I don’t know much about scripting so I don’t know where to put the code. I think I figured out that it needs to be in the loop.php file but where excactly? Can someone help me?
Thanks
grtz
Absolute rubbish don’t bother trying to help if you don’t leave clear instructions!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Is there a way to make the media string pull in images with the content limiter?
I’ve found that any plug-in that limits the number of characters on the main page automatically finds a way to ignore the
string.
Gireesh,
Please send a link to your website and please post the code in use on the sidebar.
I am not able to get the limit on the sidebar when i open the single post view, works fine on other pages
Any idea why using the_content_limit increases the number of queries with more than 20? I was using the_content_limit and i had over 300 queries on my front page. After i replaced the_content_limit with get_the_content_limit, the number of queries decreased to 65 wich is resonable. But i can’t figure out why the difference. Any suggestions?
Max,
It’s hard to tell which the_content() should be replaced because we don’t know what theme you are using. All WordPress sites are coded differently. What you want to do is locate the_content() code that specifically calls on the post that needs to be shortened. If you can give us some more information we might be able to help.
Why no one never says WHERE the_content(); needs to be replaced?! In which file? Come on, this is ridiculous!
Gabriel,
Create the Custom Field by giving it a name and the selecting the ‘Add Custom Field’ button. Now add the link to the ‘value’ area like so: http://books.google.de/books?id=gr0H_1IcHN8C&lpg=PA48&dq=subject%3A%22Business%20%26%20Economics%22%20Rating&pg=PP1&output=embed. Now set up the code like this:
<iframe frameborder="0" scrolling="no" style="border:0px" src="<?php echo get_post_meta($post->ID, 'customFieldName', $single=true) ?>" width=620 height=620></iframe>Now all that is necessary is to get the book link and enter it into the custom field keeping it separate from your post content.
Doc,
I now got the custom field. In case of the google connected ebook I want to ad the following code to be displayed as an ebook:
<iframe frameborder="0" scrolling="no" style="border:0px" src="http://books.google.de/books?id=gr0H_1IcHN8C&lpg=PA48&dq=subject%3A%22Business%20%26%20Economics%22%20Rating&pg=PP1&output=embed" width=620 height=620></iframe>Do I then need it to put it under value?
Gabriel,
Click on Screen Options and check the box next to ‘Custom Fields’. Note that this option only appears if you are in a Post or Page. For example, on the Dashboard this is not an option under ‘Screen Options’
Edit: There are settings shown, but non of them are to be customized.
Gabriel,
What version of WordPress are you using?
Just in case: The Screen Options are located in the top right corner of the Dashboard, just under “Howdy, YourName”
Another option would be to install Magic Fields, which provides Custom Fields, though this is a little more time consuming. Check to see that the Custom Fields option isn’t already activated by visiting a Post and looking through the optional fields below the WYSIWYG Editor.
Thanks Doc,
but now I can`t try that way because I don`t get screen options displayed – and I don`t remember ever been. However it should and this is a common issue as an conflict with any plugin…
Is there any other way to add an custom field without native WP?
Gabriel,
You will need to setup a Custom Field ( This is built into WordPress, no plugin needed – Screen Options > Custom Fields > Add Custom Field > “Name it: customFieldName” > Save ). Then add the name of your image file to the custom field example: myImage.jpg and finally save the post. I’ve included a simplified bit of code so you can see the major points, the ‘get_post_meta’ and the Limit Post code in action. The point being that they are separate i.e. the image is not within the post copy itself.
I only know the way to add images by putting them into the post. And that’s how it should look like. What do you mean with custom field?
Gabriel,
Just to be clear: You are inserting images directly into the post itself? If this is the case why not change that and add the images via a custom field, this way the plugin is not working with anything except the content. Let me know what you think of this idea and I will be happy to help if you need it. This is just a thought and there may be a good reason you are not doing this.
Doc4,
yes, I got that.
This is even an issue on my second site http://liteconomic.com where I haven`t got the books content on home.
Gabriel,
Have you tried using ‘get_the_content_limit’ which strips out HTML from the content? This is the reason I developed the plugin further.
Hi,
I`m with Ernst recommending if there’d be a way to allow some exceptions to the content limitation – especially to add a thumbnail image to the post.
Is that even without updating the plugin possible, just by adding some lines to the code?
Ernst,
Try using the stripped HTML version: get_the_content_limit.
Hi!
Tanks for a great plugin! How can I have a gallery at the beginning of a post without it getting chopped up? I guess the gallery reads a lot more characters than it seems like in the the HTML view?
E
Very nice, I’ve update this post…
Sunlight,
Thanks for the catch, I’ve updated the post.
don’t forget “?” after “<" before "php":
Alright. Exactly what should I send? All the theme files or just the affected files like the index, single, category, archive, sidebar…?
Yui,
Go ahead and send the theme without the images, just in case.
Yui,
It would be easier to have a login but go ahead and send over the files and I will see what I can do: info {{at}} doc4design.com
Couldn’t I just send you the files? I’m really not comfortable with handing over logins.
Yui,
Okay, this is making more sense. I’m curious if the page just has an error in it that I’m not seeing. If you don’t mind granting me temporary access to the site I would be happy to take a look. Let me know what you think and please just email any user names and passwords.
I hope I didn’t sound ungrateful when I said let’s try this again… it was because I was unable to post the comment twice before it actually worked.
Second, it’s not that I want to limit the single post itself (I don’t know why there’s a read more thing in the single entry, I didn’t put it there & it doesn’t seem to do anything). The thing I want to limit is in the sidebar, and the single post view is the only place the thing in the sidebar is not limiting. Look, I’ll show you.
[ Image links moved to pastebin: http://pastebin.com/pE141Szb ]
Yui,
I’m not certain why you would want to limit the post content on a single.php file but again it’s a matter of altering the_content:
Replace:
<?php the_content('Read the rest of this entry »'); ?>With:
<?php the_content_limit(5, "Read more . . "); ?>The number ’5′ represents the character length that should be output by the_content. Reduce this number to show fewer characters, increase it to show more.
Let’s try this again….
That code only tidied things up, it didn’t make the text limit at all. I did however notice that the problem only occurs on the single post view, whereas it works properly in pages and archives. There must be something conflicting with it. This is my single.php file:
[ Code Removed http://pastebin.com/FxBudZmb ]
Yul,
What is the theme? Try changing the_content line to
<php the_content_limit(80, ""); ?>and just delete the rest, the note is for the admin anyway. For example: