<?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>Bodu's S.E.O, Design and Social Networking  Blog &#187; the_excerpt template tag</title>
	<atom:link href="http://www.boduweb.com/blog/tag/the_excerpt-template-tag/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.boduweb.com/blog</link>
	<description>Thoughts and experiences on search engine optimisation, web design, and social networks</description>
	<lastBuildDate>Mon, 12 Apr 2010 07:48:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Shortening the_excerpt in wordpress with substr</title>
		<link>http://www.boduweb.com/blog/11200930/shortening-the_excerpt-in-wordpress-with-substr/</link>
		<comments>http://www.boduweb.com/blog/11200930/shortening-the_excerpt-in-wordpress-with-substr/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 15:30:34 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[general thoughts]]></category>
		<category><![CDATA[wordpress tips]]></category>
		<category><![CDATA[php and wordpress]]></category>
		<category><![CDATA[the_excerpt template tag]]></category>
		<category><![CDATA[wordpress the loop]]></category>

		<guid isPermaLink="false">http://www.boduweb.com/blog/?p=115</guid>
		<description><![CDATA[
			
				
			
		
Things have been very busy here for the last couple of months, so sorry for the lack of posts. We hope to resume normal posting shortly.
In the meantime, here&#8217;s a quick and simple wordpress tip that&#8217;s come in handy for us so we thought it would be good to share.
One common problem you can run [...]


Share and Enjoy:


	<a rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.boduweb.com%2Fblog%2F11200930%2Fshortening-the_excerpt-in-wordpress-with-substr%2F&amp;title=Shortening%20the_excerpt%20in%20wordpress%20with%20substr" title="Digg"><img src="http://www.boduweb.com/blog/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://sphinn.com/submit.php?url=http%3A%2F%2Fwww.boduweb.com%2Fblog%2F11200930%2Fshortening-the_excerpt-in-wordpress-with-substr%2F&amp;title=Shortening%20the_excerpt%20in%20wordpress%20with%20substr" title="Sphinn"><img src="http://www.boduweb.com/blog/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.boduweb.com%2Fblog%2F11200930%2Fshortening-the_excerpt-in-wordpress-with-substr%2F&amp;title=Shortening%20the_excerpt%20in%20wordpress%20with%20substr" title="del.icio.us"><img src="http://www.boduweb.com/blog/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.boduweb.com%2Fblog%2F11200930%2Fshortening-the_excerpt-in-wordpress-with-substr%2F&amp;t=Shortening%20the_excerpt%20in%20wordpress%20with%20substr" title="Facebook"><img src="http://www.boduweb.com/blog/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.boduweb.com%2Fblog%2F11200930%2Fshortening-the_excerpt-in-wordpress-with-substr%2F&amp;title=Shortening%20the_excerpt%20in%20wordpress%20with%20substr" title="Mixx"><img src="http://www.boduweb.com/blog/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.boduweb.com%2Fblog%2F11200930%2Fshortening-the_excerpt-in-wordpress-with-substr%2F&amp;title=Shortening%20the_excerpt%20in%20wordpress%20with%20substr" title="Google"><img src="http://www.boduweb.com/blog/wp-content/plugins/sociable/images/googlebookmark.png" title="Google" alt="Google" class="sociable-hovers" /></a>
	<a rel="nofollow" href="mailto:?subject=Shortening%20the_excerpt%20in%20wordpress%20with%20substr&amp;body=http%3A%2F%2Fwww.boduweb.com%2Fblog%2F11200930%2Fshortening-the_excerpt-in-wordpress-with-substr%2F" title="E-mail this story to a friend!"><img src="http://www.boduweb.com/blog/wp-content/plugins/sociable/images/email_link.png" title="E-mail this story to a friend!" alt="E-mail this story to a friend!" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.furl.net/storeIt.jsp?u=http%3A%2F%2Fwww.boduweb.com%2Fblog%2F11200930%2Fshortening-the_excerpt-in-wordpress-with-substr%2F&amp;t=Shortening%20the_excerpt%20in%20wordpress%20with%20substr" title="Furl"><img src="http://www.boduweb.com/blog/wp-content/plugins/sociable/images/furl.png" title="Furl" alt="Furl" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.linkedin.com/shareArticle?mini=true&url=http%3A%2F%2Fwww.boduweb.com%2Fblog%2F11200930%2Fshortening-the_excerpt-in-wordpress-with-substr%2F&title=Shortening%20the_excerpt%20in%20wordpress%20with%20substr" title="LinkedIn"><img src="http://www.boduweb.com/blog/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.spurl.net/spurl.php?url=http%3A%2F%2Fwww.boduweb.com%2Fblog%2F11200930%2Fshortening-the_excerpt-in-wordpress-with-substr%2F&amp;title=Shortening%20the_excerpt%20in%20wordpress%20with%20substr" title="Spurl"><img src="http://www.boduweb.com/blog/wp-content/plugins/sociable/images/spurl.png" title="Spurl" alt="Spurl" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.boduweb.com%2Fblog%2F11200930%2Fshortening-the_excerpt-in-wordpress-with-substr%2F&amp;title=Shortening%20the_excerpt%20in%20wordpress%20with%20substr" title="StumbleUpon"><img src="http://www.boduweb.com/blog/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://taggly.com/bookmarks.php/pass?action=add&amp;address=" title="Taggly"><img src="http://www.boduweb.com/blog/wp-content/plugins/sociable/images/taggly.png" title="Taggly" alt="Taggly" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.boduweb.com%2Fblog%2F11200930%2Fshortening-the_excerpt-in-wordpress-with-substr%2F" title="Technorati"><img src="http://www.boduweb.com/blog/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://twitthis.com/twit?url=http%3A%2F%2Fwww.boduweb.com%2Fblog%2F11200930%2Fshortening-the_excerpt-in-wordpress-with-substr%2F" title="TwitThis"><img src="http://www.boduweb.com/blog/wp-content/plugins/sociable/images/twitter.png" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a>


<br/><br/>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.boduweb.com%2Fblog%2F11200930%2Fshortening-the_excerpt-in-wordpress-with-substr%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.boduweb.com%2Fblog%2F11200930%2Fshortening-the_excerpt-in-wordpress-with-substr%2F&amp;source=boduweb&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>Things have been very busy here for the last couple of months, so sorry for the lack of posts. We hope to resume normal posting shortly.</p>
<p>In the meantime, here&#8217;s a quick and simple wordpress tip that&#8217;s come in handy for us so we thought it would be good to share.</p>
<p>One common problem you can run into, when customising wordpress themes, is the default length of  text returned by the handy template tag the_excerpt . The default, which is set at 55 words (not characters!) is often to big a chunk to fit its required purpose &#8211; that of providing a teaser for posts.</p>
<p>What to do? Well, you can add code into the functions.php file to change the default size of the_excerpt site-wide &#8211; as detailed <a href="http://wordpress.org/support/topic/231953">here </a></p>
<p>What, though, if you just want to reduce the excerpt on a specific page &#8211; for example on your home page (by default index.php)?</p>
<p>Using the simple php command  <strong>substr</strong> you can reduce the_excerpt directly in <a href="http://codex.wordpress.org/The_Loop">the loop</a>.  You&#8217;re going to have to use the get_the_excerpt hook first though, as you can&#8217;t run substr directly on the_excerpt template tag.</p>
<p>Let&#8217;s take the example of the front page:</p>
<p>The loop starts here: <strong>&lt;?php while (have_posts()) : the_post(); ?&gt;</strong> returning template tags like the_title(), the_author(), and the_excerpt() for use within the template.</p>
<p>We&#8217;re going to create a variable called $excerpt and assign the contents of get_the_excerpt() to it. So &lt;<strong>?php while (have_posts()):the_post();$excerpt=get_the_excerpt();?&gt;</strong></p>
<p>Then, wherever in your template you want to reduce the size of the_excerpt simply replace it with <strong>&lt;?php echo substr($excerpt,0,x);?&gt; </strong> where x is the number of characters (not words!) that you want to display.  So, to display an excerpt of 50 characters you would have <strong>&lt;?php echo substr($excerpt,0,50);?&gt;</strong></p>
<h2>Adding a &#8216;Read More&#8217; link</h2>
<p>You should, of course, provide a link to the full post when using the_excerpt or any variation on it. To do that, simply add <strong>&lt;a href=&#8221;&lt;?php echo the_permalink();?&gt;&#8221;&gt;[ read more...]&lt;/a&gt;</strong> immediately after your excerpt code.</p>
<p><strong><br />
</strong></p>



Share and Enjoy:


	<a rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.boduweb.com%2Fblog%2F11200930%2Fshortening-the_excerpt-in-wordpress-with-substr%2F&amp;title=Shortening%20the_excerpt%20in%20wordpress%20with%20substr" title="Digg"><img src="http://www.boduweb.com/blog/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://sphinn.com/submit.php?url=http%3A%2F%2Fwww.boduweb.com%2Fblog%2F11200930%2Fshortening-the_excerpt-in-wordpress-with-substr%2F&amp;title=Shortening%20the_excerpt%20in%20wordpress%20with%20substr" title="Sphinn"><img src="http://www.boduweb.com/blog/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.boduweb.com%2Fblog%2F11200930%2Fshortening-the_excerpt-in-wordpress-with-substr%2F&amp;title=Shortening%20the_excerpt%20in%20wordpress%20with%20substr" title="del.icio.us"><img src="http://www.boduweb.com/blog/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.boduweb.com%2Fblog%2F11200930%2Fshortening-the_excerpt-in-wordpress-with-substr%2F&amp;t=Shortening%20the_excerpt%20in%20wordpress%20with%20substr" title="Facebook"><img src="http://www.boduweb.com/blog/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.boduweb.com%2Fblog%2F11200930%2Fshortening-the_excerpt-in-wordpress-with-substr%2F&amp;title=Shortening%20the_excerpt%20in%20wordpress%20with%20substr" title="Mixx"><img src="http://www.boduweb.com/blog/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.boduweb.com%2Fblog%2F11200930%2Fshortening-the_excerpt-in-wordpress-with-substr%2F&amp;title=Shortening%20the_excerpt%20in%20wordpress%20with%20substr" title="Google"><img src="http://www.boduweb.com/blog/wp-content/plugins/sociable/images/googlebookmark.png" title="Google" alt="Google" class="sociable-hovers" /></a>
	<a rel="nofollow" href="mailto:?subject=Shortening%20the_excerpt%20in%20wordpress%20with%20substr&amp;body=http%3A%2F%2Fwww.boduweb.com%2Fblog%2F11200930%2Fshortening-the_excerpt-in-wordpress-with-substr%2F" title="E-mail this story to a friend!"><img src="http://www.boduweb.com/blog/wp-content/plugins/sociable/images/email_link.png" title="E-mail this story to a friend!" alt="E-mail this story to a friend!" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.furl.net/storeIt.jsp?u=http%3A%2F%2Fwww.boduweb.com%2Fblog%2F11200930%2Fshortening-the_excerpt-in-wordpress-with-substr%2F&amp;t=Shortening%20the_excerpt%20in%20wordpress%20with%20substr" title="Furl"><img src="http://www.boduweb.com/blog/wp-content/plugins/sociable/images/furl.png" title="Furl" alt="Furl" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.linkedin.com/shareArticle?mini=true&url=http%3A%2F%2Fwww.boduweb.com%2Fblog%2F11200930%2Fshortening-the_excerpt-in-wordpress-with-substr%2F&title=Shortening%20the_excerpt%20in%20wordpress%20with%20substr" title="LinkedIn"><img src="http://www.boduweb.com/blog/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.spurl.net/spurl.php?url=http%3A%2F%2Fwww.boduweb.com%2Fblog%2F11200930%2Fshortening-the_excerpt-in-wordpress-with-substr%2F&amp;title=Shortening%20the_excerpt%20in%20wordpress%20with%20substr" title="Spurl"><img src="http://www.boduweb.com/blog/wp-content/plugins/sociable/images/spurl.png" title="Spurl" alt="Spurl" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.boduweb.com%2Fblog%2F11200930%2Fshortening-the_excerpt-in-wordpress-with-substr%2F&amp;title=Shortening%20the_excerpt%20in%20wordpress%20with%20substr" title="StumbleUpon"><img src="http://www.boduweb.com/blog/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://taggly.com/bookmarks.php/pass?action=add&amp;address=" title="Taggly"><img src="http://www.boduweb.com/blog/wp-content/plugins/sociable/images/taggly.png" title="Taggly" alt="Taggly" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://technorati.com/faves?add=http%3A%2F%2Fwww.boduweb.com%2Fblog%2F11200930%2Fshortening-the_excerpt-in-wordpress-with-substr%2F" title="Technorati"><img src="http://www.boduweb.com/blog/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://twitthis.com/twit?url=http%3A%2F%2Fwww.boduweb.com%2Fblog%2F11200930%2Fshortening-the_excerpt-in-wordpress-with-substr%2F" title="TwitThis"><img src="http://www.boduweb.com/blog/wp-content/plugins/sociable/images/twitter.png" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.boduweb.com/blog/11200930/shortening-the_excerpt-in-wordpress-with-substr/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
