I was first intrigued by the WordPress theme Squible to have one featured post on the front page with links to previous posts. I liked the implemenation, and Mr. Parlin did a good job working with an existing plugin. After changing themes on my main blog I decided that I wanted to implement that same look and feel. Let’s go through a tutorial.
The Necessary Components
Editing the Plugin
Let’s say that I want to limit the featured post preview to 450 characters, but let’s add onto that fact that this excerpt is italicized in your main post. What this does is then bring that unclosed tag onto the main page so some of your front page content is now italicized. How can we prevent this? We need the striptags() PHP function.
Then open up the plugin in an editor (suggest CHMOD on the plugin and editing it inside WordPress), and look for the following line:
$content = str_replace(']]>', ']]>', $content);
Under this line we are going to strip the HTML tags from the $content variable. Add the following line:
$content = strip_tags($content);
Edit Index Page
The following instructions come from the Limit Posts page:
Go into your index.php file and change the function the_content() with the_content_limit($max_characters, $link_text) where:
$max_characters: maximum amount of characters shown for an entry in the main page (index.php)
$link_text: text that is used to generate the link to the whole article.
I use the following in my theme:
Say you would like for anchor tags to be allowed but not other HTML; the PHP function can accept an argument to allow code. Here is code to allow anchor tags: