<?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>WpFunc &#187; recipe</title>
	<atom:link href="http://wpfunc.com/tag/recipe/feed" rel="self" type="application/rss+xml" />
	<link>http://wpfunc.com</link>
	<description>Awesome, Quick, Simple WordPress Functions!</description>
	<lastBuildDate>Thu, 01 Dec 2011 01:17:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Related Posts, Without any Plugin!</title>
		<link>http://wpfunc.com/general/related-posts-without-any-plugin.html</link>
		<comments>http://wpfunc.com/general/related-posts-without-any-plugin.html#comments</comments>
		<pubDate>Mon, 20 Jul 2009 08:00:47 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[recipe]]></category>
		<category><![CDATA[Related posts]]></category>
		<category><![CDATA[without plugin]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.wpfunc.com/?p=81</guid>
		<description><![CDATA[Hi everybody. You can show your related posts without any plugin. It&#8217;is important for visitors i think. Because they can discover your blog with that area. This code shows your same-tagged posts. Some plugins do this but why use plugin if you have a powerfull theme :). You can change posts number too. Lets Begin&#8230;

We [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Hi everybody. You can show your related posts without any plugin. It&#8217;is important for visitors i think. Because they can discover your blog with that area. This code shows your same-tagged posts. Some plugins do this but why use plugin if you have a powerfull theme :). You can change posts number too. Lets Begin&#8230;<span id="more-81"></span></p>
<p style="text-align: justify;"><span class="attention"><strong>With this function/recipe you will change your core single.php file. If you have no information about WordPress coding -so you&#8217;re a newbie- you can get some support if you send a mail to me. Don&#8217;t touch your single.php if you don&#8217;t know about WordPress</strong></span></p>
<p style="text-align: justify;">We will change our themes <strong><em>single.php</em></strong>. Make bakcup and be careful. After backup open <strong>single.php</strong> and copy this code after loop or content.</p>
<h3>Here is the code;</h3>
<pre class="brush: plain; title: ; notranslate">&lt;?php
      //for use in the loop, list 5 post titles related to first tag on current post
      $tags = wp_get_post_tags($post-&gt;ID);
if ($tags) {
echo 'Related Posts';
$first_tag = $tags[0]-&gt;term_id;
$args=array(
'tag__in' =&gt; array($first_tag),
'post__not_in' =&gt; array($post-&gt;ID),
'showposts'=&gt;5,
'caller_get_posts'=&gt;1
);
$my_query = new WP_Query($args);
if( $my_query-&gt;have_posts() ) {
while ($my_query-&gt;have_posts()) : $my_query-&gt;the_post(); ?&gt;
     &lt;p&gt;&lt;a href=&quot;&lt;?php the_permalink() ?&gt;&quot; rel=&quot;bookmark&quot; title=&quot;Permanent Link to &lt;?php the_title_attribute(); ?&gt;&quot;&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/p&gt;
    &lt;?php
  endwhile;
  }
 }
?&gt; </pre>
<p>Save single.php. And then refresh your page. Related Posts are display after content. :) If you change &#8216;<em><strong>showpost=5</strong></em>&#8216; (<em><strong>the 5 is post number</strong></em>) 5 to 4,6,9,etc. Related posts number will change.</p>
<p>That&#8217;s All! Have a nice day!</p>
]]></content:encoded>
			<wfw:commentRss>http://wpfunc.com/general/related-posts-without-any-plugin.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

