<?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>msafi.com &#187; YARPP</title>
	<atom:link href="http://msafi.com/tag/yarpp/feed/" rel="self" type="application/rss+xml" />
	<link>http://msafi.com</link>
	<description>The friendly blog of MK Safi</description>
	<lastBuildDate>Wed, 28 Jul 2010 22:16:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Fix Yet Another Related Posts Plugin (YARPP) Widget and Add it to the Sidebar</title>
		<link>http://msafi.com/fix-yet-another-related-posts-plugin-yarpp-widget-and-add-it-to-the-sidebar/</link>
		<comments>http://msafi.com/fix-yet-another-related-posts-plugin-yarpp-widget-and-add-it-to-the-sidebar/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 09:20:37 +0000</pubDate>
		<dc:creator>MK</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[YARPP]]></category>

		<guid isPermaLink="false">http://msafi.com/?p=781</guid>
		<description><![CDATA[YARPP is an essential WordPress plugin because it improves the navigation of your blog and therefore it adds more search engine optimization weight to your pages. Most blogs list links to related posts at the bottom of each post page. Another great place to list related links is in the sidebar. YARPP does come with [...]


Related posts:<ol><li><a href='http://msafi.com/clean-your-wordpress-sidebar-to-improve-navigation-and-seo/' rel='bookmark' title='Permanent Link: Clean Your WordPress Sidebar to Improve Navigation and SEO!'>Clean Your WordPress Sidebar to Improve Navigation and SEO!</a></li>
<li><a href='http://msafi.com/how-to-make-posts-have-different-sidebar-from-the-rest-of-wordpress-blog/' rel='bookmark' title='Permanent Link: Give Posts Their Own Sidebar in WordPress'>Give Posts Their Own Sidebar in WordPress</a></li>
<li><a href='http://msafi.com/sensible-use-of-tags-in-a-wordpress-blog/' rel='bookmark' title='Permanent Link: Sensible Use of &#8220;Tags&#8221; in a WordPress Blog'>Sensible Use of &#8220;Tags&#8221; in a WordPress Blog</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>YARPP is an essential WordPress plugin because it improves the navigation of your blog and therefore it adds more search engine optimization weight to your pages.</p>
<p>Most blogs list links to related posts at the bottom of each post page. Another great place to list related links is in the sidebar. YARPP does come with a sidebar widget. But as you can see in the <a href="http://wordpress.org/tags/yet-another-related-posts-plugin">plugin&#8217;s forum</a>, many people are having problems with it. Also, it doesn&#8217;t allow you to separate the style and template from the main related posts links. Even the author of the plugin <a href="http://wordpress.org/support/topic/345774?replies=5#post-1330297">has disowned</a> the built-in widget!</p>
<p>What I&#8217;ll show you here is how you can create your own YARPP sidebar widget and give it a different style and template from the main related posts links.<span id="more-781"></span></p>
<h2>PHP Code for the Widget</h2>
<p>Here&#8217;s the entire PHP code for this widget.</p>
<pre class="brush: php;">add_action('widgets_init', create_function('', 'register_widget(&quot;Related_Posts_Widget&quot;);'));
class Related_Posts_Widget extends WP_Widget
{
    function Related_Posts_Widget() {
        parent::WP_Widget(false, $name = 'Related Posts Widget');
    }

    function widget($args, $instance)
    {
		extract($args);
		extract($instance);

		echo	$before_widget;

		echo	related_posts(array('template_file'=&gt;'yarpp-template-widget.php'));

		echo	$after_widget;
    }

    function update($new_instance, $old_instance)
    {
        return $new_instance;
    }
}</pre>
<p>Copy and paste the code above in <code>functions.php</code> in your theme&#8217;s folder. You can now go to &#8220;Appearance&#8221; -&gt; &#8220;Widgets&#8221; and you&#8217;ll see a new widget called &#8220;Related Posts Widget&#8221;. Simply drag it to your sidebar! But wait. Before you do that, you&#8217;ll have to create a template file for the widget.</p>
<h2>Widget Template File</h2>
<p>The template file is mostly made up of the HTML that the plugin will use to display your list of related posts.</p>
<p>For the widget code above to work, you&#8217;ll have to create a new template file and name it: <code>yarpp-template-widget.php</code>. The file should exist with the rest of YARPP template files, which is in the main folder of your theme.</p>
<p>The content of my <code>yarpp-template-widget.php</code><em> </em>look like this:</p>
<pre class="brush: php;">&lt;?php /*
Example template
Author: mitcho (Michael Yoshitaka Erlewine)
*/
?&gt;
&lt;?php if ($related_query-&gt;have_posts()):?&gt;

&lt;h2 class=&quot;widgettitle&quot;&gt;Other Interesting Posts&lt;/h2&gt;
&lt;ul&gt;
	&lt;?php while ($related_query-&gt;have_posts()) : $related_query-&gt;the_post(); ?&gt;
		&lt;li&gt;&lt;a href=&quot;&lt;?php the_permalink() ?&gt;&quot; rel=&quot;bookmark&quot;&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;!-- (&lt;?php the_score(); ?&gt;)--&gt;&lt;/li&gt;
	&lt;?php endwhile; ?&gt;
&lt;/ul&gt;
&lt;?php endif; ?&gt;</pre>
<p>You&#8217;ll need to know some HTML and PHP to modify the template.</p>
<p>But with this file in place, you can now simply go to the Widgets panel in WordPress admin area, and you&#8217;ll see &#8220;Related Posts Widget&#8221;, which you can add to any sidebar!</p>
<p>I hope you found this tutorial helpful. If you have any questions, comments or suggestions, post them below <img src='http://msafi.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>


<p>Related posts:<ol><li><a href='http://msafi.com/clean-your-wordpress-sidebar-to-improve-navigation-and-seo/' rel='bookmark' title='Permanent Link: Clean Your WordPress Sidebar to Improve Navigation and SEO!'>Clean Your WordPress Sidebar to Improve Navigation and SEO!</a></li>
<li><a href='http://msafi.com/how-to-make-posts-have-different-sidebar-from-the-rest-of-wordpress-blog/' rel='bookmark' title='Permanent Link: Give Posts Their Own Sidebar in WordPress'>Give Posts Their Own Sidebar in WordPress</a></li>
<li><a href='http://msafi.com/sensible-use-of-tags-in-a-wordpress-blog/' rel='bookmark' title='Permanent Link: Sensible Use of &#8220;Tags&#8221; in a WordPress Blog'>Sensible Use of &#8220;Tags&#8221; in a WordPress Blog</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://msafi.com/fix-yet-another-related-posts-plugin-yarpp-widget-and-add-it-to-the-sidebar/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>
