<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>bavotasan.com &#187; the_excerpt</title>
	<atom:link href="http://bavotasan.com/tag/the_excerpt/feed/" rel="self" type="application/rss+xml" />
	<link>http://bavotasan.com</link>
	<description>by c.bavota</description>
	<lastBuildDate>Tue, 07 Feb 2012 15:42:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Quick &amp; Easy Excerpt Mods Coming in WordPress 2.9</title>
		<link>http://bavotasan.com/2009/quick-easy-excerpt-mods-coming-in-wordpress-2-9/</link>
		<comments>http://bavotasan.com/2009/quick-easy-excerpt-mods-coming-in-wordpress-2-9/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 15:14:55 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Change]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[default]]></category>
		<category><![CDATA[end]]></category>
		<category><![CDATA[excerpt]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[Function]]></category>
		<category><![CDATA[length]]></category>
		<category><![CDATA[mods]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[piece]]></category>
		<category><![CDATA[power]]></category>
		<category><![CDATA[return]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[the_excerpt]]></category>
		<category><![CDATA[version]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=1393</guid>
		<description><![CDATA[I just stumbled across these two little pieces of code and thought that they might be useful to some people out there who want to mess around with the default settings for the_excerpt() function in WordPress. The first one gives you the power to change the number of words displayed by the function the_excerpt(), and [...]]]></description>
			<content:encoded><![CDATA[<p>I just stumbled across these two little pieces of code and thought that they might be useful to some people out there who want to mess around with the default settings for <code>the_excerpt()</code> function in WordPress. The first one gives you the power to change the number of words displayed by the function <code>the_excerpt()</code>, and yes, you can have more than 55 words. The second piece of code allows you to change the trailing [...] that appears at the end of your excerpt.<br />
<span id="more-1393"></span><br />
Both features are set to be added to version 2.9 of WordPress, but the first currently works in version 2.8.5. Just add these to your theme&#8217;s functions.php file.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> new_excerpt_length<span style="color: #009900;">&#40;</span><span style="color: #000088;">$length</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #cc66cc;">20</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'excerpt_length'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'new_excerpt_length'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Change the number &#8220;20&#8243; to whatever number you want.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> new_excerpt_more<span style="color: #009900;">&#40;</span><span style="color: #000088;">$more</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'[.....]'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'excerpt_more'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'new_excerpt_more'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Change &#8220;[.....]&#8221; to whatever you want.</p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2009/quick-easy-excerpt-mods-coming-in-wordpress-2-9/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Excerpt or Content Word Limit in WordPress: Redux</title>
		<link>http://bavotasan.com/2009/limiting-the-number-of-words-in-your-excerpt-or-content-in-wordpress/</link>
		<comments>http://bavotasan.com/2009/limiting-the-number-of-words-in-your-excerpt-or-content-in-wordpress/#comments</comments>
		<pubDate>Mon, 16 Feb 2009 18:51:20 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[ability]]></category>
		<category><![CDATA[Array]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[content]]></category>
		<category><![CDATA[Content Word]]></category>
		<category><![CDATA[count]]></category>
		<category><![CDATA[excerpt]]></category>
		<category><![CDATA[Function]]></category>
		<category><![CDATA[img]]></category>
		<category><![CDATA[limit]]></category>
		<category><![CDATA[Lt]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[pop]]></category>
		<category><![CDATA[Preg]]></category>
		<category><![CDATA[Programmers]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[return]]></category>
		<category><![CDATA[the_excerpt]]></category>
		<category><![CDATA[way]]></category>
		<category><![CDATA[while]]></category>
		<category><![CDATA[Word Limit]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress hack]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=269</guid>
		<description><![CDATA[This is just a revamp of a function I wrote a while back to add the ability to limit the number of words displayed when you call the excerpt or content. As it stands, the max number of words for the excerpt is 55. There is a new function with WP 2.9 to increase this [...]]]></description>
			<content:encoded><![CDATA[<p>This is just a revamp of a function I wrote a while back to add the ability to limit the number of words displayed when you call the excerpt or content. As it stands, the max number of words for the excerpt is 55. There is a new function with WP 2.9 to increase this number. Check out <a href="http://bavotasan.com/?p=1393">Quick &#038; Easy Excerpt Mods Coming in WordPress 2.9</a> for more on that subject.<br />
<span id="more-269"></span><br />
Add the following code to your functions.php file.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> excerpt<span style="color: #009900;">&#40;</span><span style="color: #000088;">$limit</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$excerpt</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">,</span> get_the_excerpt<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$limit</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$excerpt</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&gt;=</span><span style="color: #000088;">$limit</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #990000;">array_pop</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$excerpt</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$excerpt</span> <span style="color: #339933;">=</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$excerpt</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'...'</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$excerpt</span> <span style="color: #339933;">=</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$excerpt</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>	
  <span style="color: #000088;">$excerpt</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'`\[[^\]]*\]`'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span><span style="color: #000088;">$excerpt</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$excerpt</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> content<span style="color: #009900;">&#40;</span><span style="color: #000088;">$limit</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">,</span> get_the_content<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$limit</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&gt;=</span><span style="color: #000088;">$limit</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #990000;">array_pop</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'...'</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>	
  <span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/\[.+\]/'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> apply_filters<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'the_content'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
  <span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">']]&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">']]&amp;gt;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Now, instead of using the_content() or the_excerpt in your loop, use excerpt($limit) or content($limit). </p>
<p>If you want to limit your excerpt to 25 words the code would look like this:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> excerpt<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">25</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></td></tr></table></div>

<p>I also created a plugin for this that you can download at <a href="http://wordpress.org/extend/plugins/content-and-excerpt-word-limit/">http://wordpress.org/extend/plugins/content-and-excerpt-word-limit/</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2009/limiting-the-number-of-words-in-your-excerpt-or-content-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>85</slash:comments>
		</item>
	</channel>
</rss>

