1.0
Limit-Post Add-On
13. July 2009 · Author: Dale Crum
76 Comments

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

  1. Download the plugin and expand it.
  2. Copy the limitpost-addon folder into your plugins folder ( wp-content/plugins ).
  3. Log-in to the WordPress administration panel and visit the Plugins page.
  4. Locate the Limit Post plugin and click on the activate link.
  5. Replace the_content(); with the_content_limit(200, "continue..."); or
  6. Replace the_content(); with get_the_content_limit(200, "continue...");

76 Comments

  1. 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.

  2. 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?

  3. 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’

  4. Edit: There are settings shown, but non of them are to be customized.

Leave A Comment

Please wrap any code within the <code> tag to display properly

I've been thinking a lot lately about stability versus spontaneity, freedom versus structure. Sometimes I find myself saying things like, "You can't grow unless you try new things,...

As I sit here at my desk with yet another article deadline staring me in the face, I can't help but wonder if I'm the only one who is plagued by the appealing face of procrastination....

In the advertising business we all aspire to do something big, something memorable, something great that has never been done before; unfortunately not very many of us get the opportunity...

I am under the personal belief that post titles should be short, sweet and precise enough to get the point across without sounding like an awkward newspaper headline. Sadly not all...

If you're involved in the world of design, whether it is by trade or business necessity, then you are probably familiar with the term "spec design", also known as "crowdsourcing". The...