<?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>michaelciccarelli.com &#187; seo</title>
	<atom:link href="http://michaelciccarelli.com/tag/seo/feed/" rel="self" type="application/rss+xml" />
	<link>http://michaelciccarelli.com</link>
	<description></description>
	<lastBuildDate>Sun, 07 Mar 2010 23:19:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Better Anchor Text On WordPress Post Excerpts</title>
		<link>http://michaelciccarelli.com/2009/02/better-anchor-text-on-wordpress-post-excerpts/</link>
		<comments>http://michaelciccarelli.com/2009/02/better-anchor-text-on-wordpress-post-excerpts/#comments</comments>
		<pubDate>Tue, 24 Feb 2009 00:51:32 +0000</pubDate>
		<dc:creator>mc</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[excerpt]]></category>
		<category><![CDATA[seo]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://michaelciccarelli.com/?p=539</guid>
		<description><![CDATA[I tend to use post excerpts (the_excerpt) on the home page and archive views of a blog rather than full posts (the_content). Using the excerpt controls the size of each post and provides a clean interface for readers to scan content. However, I think it&#8217;s better to have a permalink with custom anchor text trailing [...]]]></description>
			<content:encoded><![CDATA[<p>I tend to use post excerpts (the_excerpt) on the home page and archive views of a blog rather than full posts (the_content). Using the excerpt controls the size of each post and provides a clean interface for readers to scan content. However, I think it&#8217;s better to have a permalink with custom anchor text trailing each post excerpt rather than the default [...] text providing no usability.</p>
<p>There are plugins for this, such as <a href="http://robsnotebook.com/the-excerpt-reloaded">The Excerpt Reloaded</a>. I for one always try to keep plugin usage to a minimum and this can be done very easily by adding a small function to your theme files.</p>
<p>Open your theme&#8217;s functions file or functions.php in your themes directory, if you doen&#8217;t see a functions.php file you can create it, and add the following code:</p>
<p><pre><code>//function to replace trailing text on the_excerpt 
function customtrail_excerpt($text)&nbsp;&nbsp;
{&nbsp;&nbsp;
return str_replace(&#039;[...]&#039;, &#039;&lt;a href=&quot;&#039;. get_permalink($post-&gt;ID) . &#039;&quot;&gt;&#039; . &#039;Continue Reading &amp;hellip;&#039; . &#039;&lt;/a&gt;&#039;, $text);&nbsp;&nbsp;
}&nbsp;&nbsp;
add_filter(&#039;the_excerpt&#039;, &#039;customtrail_excerpt&#039;); </code></pre></p>
<p>Your post excerpts should now look something like this..</p>
<p><img src="http://michaelciccarelli.com/wp-content/uploads/2009/02/default.png" class="centered" /></p>
<h3>making the trailing text S.E.O. friendly anchor text</h3>
<p>Making the anchor text dynamic instead of a default &#8220;Read Now&#8221; or &#8220;Continue Reading&#8221; is great for Search Engine Optimization. First we need to add another function to our theme files (functions.php) that will go out and get the content of a custom field from our posts meta data. This custom field should be named &#8220;anchor&#8221; and if you populate this field while writing a post, your custom anchor text will display at the end of each post excerpt as anchor text linking to the permalink of the post, otherwise a default &#8220;Read More&#8230;&#8221; will display in the brackets.</p>
<p>Below is the updated code featuring the additional custom fields function and also some changes to the original Custom Trailing Text function I posted above. Instead of just returning static text it will look for the custom field of &#8220;anchor&#8221; and display this text, otherwise display the default &#8220;Read More&#8230;&#8221; trailing each post excerpt.</p>
<p><pre><code>//function to get custom fields outside the loop&nbsp;&nbsp;&nbsp;&nbsp;
function get_custom_field($key, $echo = FALSE) {
&nbsp;&nbsp;global $post;
&nbsp;&nbsp;$custom_field = get_post_meta($post-&gt;ID, $key, true);
&nbsp;&nbsp;if ($echo == FALSE) return $custom_field;
&nbsp;&nbsp;echo $custom_field;
}
//function to replace trailing text on the_excerpt&nbsp;&nbsp;
function customtrail_excerpt($text)&nbsp;&nbsp;{&nbsp;&nbsp;
&nbsp;&nbsp;$customanchor = get_custom_field(&#039;anchor&#039;, false);
&nbsp;&nbsp;&nbsp;&nbsp;if(!empty($customanchor)): 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$anchortext = $customanchor;
&nbsp;&nbsp;&nbsp;&nbsp;endif;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;if(empty($customanchor)):
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$anchortext = &#039;Continue Reading &amp;hellip;&#039;;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;endif; 
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;return str_replace(&#039;[...]&#039;, &#039;[&lt;a href=&quot;&#039;. get_permalink($post-&gt;ID) . &#039;&quot;&gt;&#039; .&nbsp;&nbsp;$anchortext . &#039;&lt;/a&gt;]&#039;, $text);&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;add_filter(&#039;the_excerpt&#039;, &#039;customtrail_excerpt&#039;);&nbsp;&nbsp;
 ?&gt;</code></pre></p>
<p>Your post excerpts should now look something like this&#8230;</p>
<p><img src="http://michaelciccarelli.com/wp-content/uploads/2009/02/custom.png" class="centered" /></p>
]]></content:encoded>
			<wfw:commentRss>http://michaelciccarelli.com/2009/02/better-anchor-text-on-wordpress-post-excerpts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
