<?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; single.php</title>
	<atom:link href="http://wpfunc.com/tag/single-php/feed" rel="self" type="application/rss+xml" />
	<link>http://wpfunc.com</link>
	<description>Awesome, Quick, Simple WordPress Functions!</description>
	<lastBuildDate>Sun, 06 May 2012 02:21:37 +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>Catch the First Image (Upgraded)</title>
		<link>http://wpfunc.com/wordpress/catch-the-first-image-upgraded.html</link>
		<comments>http://wpfunc.com/wordpress/catch-the-first-image-upgraded.html#comments</comments>
		<pubDate>Sat, 12 Nov 2011 00:42:34 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[catch the first image]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[custom field]]></category>
		<category><![CDATA[first image]]></category>
		<category><![CDATA[full]]></category>
		<category><![CDATA[functions.php]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[index.php]]></category>
		<category><![CDATA[latest]]></category>
		<category><![CDATA[single.php]]></category>
		<category><![CDATA[thumb]]></category>
		<category><![CDATA[thumbnail]]></category>
		<category><![CDATA[timthumb]]></category>
		<category><![CDATA[upgraded]]></category>

		<guid isPermaLink="false">http://www.wpfunc.com/?p=509</guid>
		<description><![CDATA[Brian asked me here about Catch the First image function can be upgrade. I was coded this function for my Turkish blog for Home Page thumbs. If you set no image about post (not the wordpress post thumb feature, if you dont upload any image) this function get custom (default) image for this. Let&#8217;s Begin&#8230; [...]]]></description>
			<content:encoded><![CDATA[<p>Brian asked me <a href="http://www.wpfunc.com/wordpress/catch-the-first-image.html/comment-page-1#comment-949" target="_blank">here</a> about <a href="http://www.wpfunc.com/wordpress/catch-the-first-image.html" title="Catch the First Image" target="_blank">Catch the First image function</a> can be upgrade. I was coded this function for my Turkish blog for Home Page thumbs. If you set no image about post (not the wordpress post thumb feature, if you dont upload any image) this function get custom (default) image for this. Let&#8217;s Begin&#8230;<span id="more-509"></span></p>
<h4>The Code;</h4>
<p>You will edit your theme&#8217;s <strong>functions.php</strong>. Because of this you should <strong>backup</strong> before. File&#8217;s path is <strong>/wp-content/themes/your-theme/functions.php</strong></p>
<pre class="brush: php; title: ; notranslate">// Get Image Attachments
function sa_get_image($postid=0, $size='thumbnail') { //it can be thumbnail or full
	if ($postid&lt;1)
	$postid = get_the_ID();
	$thumb = get_post_meta($postid, &quot;thumb&quot;, TRUE); // Declare the custom field for the image
	if ($thumb != null or $thumb != '') {
		echo $thumb;
	}
	elseif ($images = get_children(array( //If you upload an image function gets first image
		'post_parent' =&gt; $postid,
		'post_type' =&gt; 'attachment',
		'numberposts' =&gt; '1',
                'orderby' =&gt; 'menu_order',
                'order' =&gt; 'ASC', //If reverse use DESC
		'post_mime_type' =&gt; 'image', )))
		foreach($images as $image) {
			$thumbnail=wp_get_attachment_image_src($image-&gt;ID, $size);
			?&gt;
	&lt;?php echo $thumbnail[0]; ?&gt;
	&lt;?php }
		else { //If you don't upload or declare as thumb custom field func. gets custom (default) image
		echo get_bloginfo ( 'template_directory' ); //same as wp-content/themes/your-theme/
		echo '/images/image-pending.gif'; // Put this image into your themes images folder and set the path here
	}
}</pre>
<p>You can use this function with your several files like index.php, single.php or anything. </p>
<pre class="brush: php; title: ; notranslate">&lt;img src=&quot;&lt;?php sa_get_image($post-&gt;ID, 'thumbnail'); ?&gt;&quot; /&gt;</pre>
<p>If you set your thumbnail size 100*100 from wordpress you can get a thumbnail image where you want. Also you can use another function with that. You can style your image&#8217;s div or you can use timthumb.</p>
<h4>Without Timthumb;</h4>
<pre class="brush: php; title: ; notranslate">// Show Post Thumbnails
function sa_show_thumb_tim() {
?&gt;
&lt;a href=&quot;&lt;?php the_permalink() ?&gt;&quot; rel=&quot;bookmark&quot;&gt;&lt;img class=&quot;thumb&quot; width=&quot;100&quot; height&quot;100&quot; src=&quot;&lt;?php sa_get_image($post-&gt;ID, 'full'); ?&gt;&quot; alt=&quot;&lt;?php the_title(); ?&gt;&quot; /&gt;&lt;/a&gt;
&lt;?php
}</pre>
<p>You can use this like this directly. Because we coded function with <code>img</code> tag.</p>
<pre class="brush: php; title: ; notranslate">&lt;?php sa_show_thumb(); ?&gt;</pre>
<h4>With Timthumb;</h4>
<pre class="brush: php; title: ; notranslate">// Show Post Thumbnails With TimThumb
function sa_show_thumb_tim() {
?&gt;
&lt;a href=&quot;&lt;?php the_permalink() ?&gt;&quot; rel=&quot;bookmark&quot;&gt;&lt;img class=&quot;thumb&quot; src=&quot;&lt;?php bloginfo('template_directory'); ?&gt;/timthumb.php?src=&lt;?php sa_get_image($post-&gt;ID, 'full'); ?&gt;&amp;amp;h=100&amp;amp;w=100&amp;amp;zc=1&quot; alt=&quot;&lt;?php the_title(); ?&gt;&quot; /&gt;&lt;/a&gt;
&lt;?php
}</pre>
<p>You can use this like this directly. Because we coded function with <code>img</code> tag and we add timthumb function. You can get the latest version of timhtumb <a href="http://code.google.com/p/timthumb/" target="_blank">here</a>. And you have to put <strong>timthumb.php</strong> into your theme&#8217;s folder.</p>
<pre class="brush: php; title: ; notranslate">&lt;?php sa_show_thumb_tim(); ?&gt;</pre>
<p>Best Regards</p>
]]></content:encoded>
			<wfw:commentRss>http://wpfunc.com/wordpress/catch-the-first-image-upgraded.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Show word counts on your posts!</title>
		<link>http://wpfunc.com/wordpress/show-word-counts-on-your-posts.html</link>
		<comments>http://wpfunc.com/wordpress/show-word-counts-on-your-posts.html#comments</comments>
		<pubDate>Fri, 09 Oct 2009 19:39:14 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[functions.php]]></category>
		<category><![CDATA[single.php]]></category>
		<category><![CDATA[word count]]></category>

		<guid isPermaLink="false">http://www.wpfunc.com/?p=247</guid>
		<description><![CDATA[I konw there are some plugin about that but you can do that with a simple code. No need plugins. If you want to add some attractive code to show  word count on your posts only edit two file and use a short-code&#8230; Here is the code; We will change your theme&#8217;s functions.php and single.php, [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">I konw there are some plugin about that but you can do that with a simple code. No need plugins. If you want to add some attractive code to show  word count on your posts only edit two file and use a short-code&#8230;<span id="more-247"></span></p>
<h3>Here is the code;</h3>
<p style="text-align: justify;"><strong>We will change your theme&#8217;s functions.php and single.php, because of this wou need to make the backup this files</strong>. First the code of  <strong><span style="color: #ff0000;">functions.php</span></strong>;</p>
<pre class="brush: plain; title: ; notranslate">function count_words($str){
     $words = 0;
     $str = eregi_replace(&quot; +&quot;, &quot; &quot;, $str);
     $array = explode(&quot; &quot;, $str);
     for($i=0;$i &lt; count($array);$i++)
 	 {
         if (eregi(&quot;[0-9A-Za-zÀ-ÖØ-öø-ÿ]&quot;, $array[$i]))
             $words++;
     }
     return $words;
 }
</pre>
<p style="text-align: justify;">Here is the code of <strong><span style="color: #ff0000;">sinlge.php</span></strong>;</p>
<pre class="brush: plain; title: ; notranslate">Word count: &lt;?php echo count_words($post-&gt;post_content); ?&gt;</pre>
<p style="text-align: justify;">After you placed this code to single.php the code count your words.<br />
That&#8217;s all. Have a nice day!</p>
]]></content:encoded>
			<wfw:commentRss>http://wpfunc.com/wordpress/show-word-counts-on-your-posts.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Show your Mood to Readers.</title>
		<link>http://wpfunc.com/wordpress/show-your-mood-to-readers.html</link>
		<comments>http://wpfunc.com/wordpress/show-your-mood-to-readers.html#comments</comments>
		<pubDate>Wed, 23 Sep 2009 22:51:01 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[custom field]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[index.php]]></category>
		<category><![CDATA[mood]]></category>
		<category><![CDATA[show mood]]></category>
		<category><![CDATA[single.php]]></category>

		<guid isPermaLink="false">http://www.wpfunc.com/?p=208</guid>
		<description><![CDATA[Do you want to show your mood to your readers on each post? If you want to do this just follow this article and learn how to show your mood with a custom field. Firstly i want to ask you; Where want to show your mood, in single post or site index or both of them? If [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Do you want to show your mood to your readers on each post? If you want to do this just follow this article and learn how to show your mood with a custom field.<span id="more-208"></span></p>
<p style="text-align: justify;">Firstly i want to ask you; Where want to show your mood, in single post or site index or both of them? If you want to show this in single post just modify your theme&#8217;s single.php, if you want to show this only in index, modify the your theme&#8217;s <strong>index.php</strong> or you want to show in both of this areas, modify <strong>index.php</strong> and<strong> single.php</strong> together.</p>
<p style="text-align: justify;">Just Copy this code below and paste it in <strong>index.php</strong> or <strong>single.php</strong>&#8216;s loop areas (After your article ord before article, where you want).</p>
<h3>Here is the code;</h3>
<pre class="brush: plain; title: ; notranslate">$customField = get_post_custom_values(&quot;mood&quot;);
if (isset($customField[0])) {
echo &quot;My Mood: &quot;.$customField[0];
</pre>
<p style="text-align: justify;">Now Just create a customfield with named &#8216;<strong>mood</strong>&#8216; and add this custom field when you write an article.</p>
]]></content:encoded>
			<wfw:commentRss>http://wpfunc.com/wordpress/show-your-mood-to-readers.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Add Comment RSS Link to Every Post</title>
		<link>http://wpfunc.com/wordpress/add-comment-rss-link-to-every-post.html</link>
		<comments>http://wpfunc.com/wordpress/add-comment-rss-link-to-every-post.html#comments</comments>
		<pubDate>Wed, 29 Jul 2009 09:03:18 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[posts]]></category>
		<category><![CDATA[RSS]]></category>
		<category><![CDATA[single.php]]></category>
		<category><![CDATA[theme]]></category>

		<guid isPermaLink="false">http://www.wpfunc.com/?p=133</guid>
		<description><![CDATA[Some of my friend asked me about Comment RSS Links. Some theme have a design for this , so there is a RSS Feed link in every post. You can add your Comment RSS link to your theme. If you want to add RSS lets begin&#8230; Here is the code; If you add this code [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Some of my friend asked me about Comment RSS Links. Some theme have a design for this , so there is a RSS Feed link in every post. You can add your Comment RSS link to your theme. If you want to add RSS lets begin&#8230;<span id="more-133"></span></p>
<h3>Here is the code;</h3>
<pre class="brush: plain; title: ; notranslate">&lt;?php comments_rss_link('» Comments RSS Feed'); ?&gt;</pre>
<p>If you add this code to in the Loop of your theme&#8217;s <span style="color: #ff0000;"><em><strong>single.php</strong></em></span> you have a RSS link on every post.</p>
<p>That&#8217;s All. Have A nice Day!</p>
]]></content:encoded>
			<wfw:commentRss>http://wpfunc.com/wordpress/add-comment-rss-link-to-every-post.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Popular Posts, Without any Plugin!</title>
		<link>http://wpfunc.com/wordpress/popular-posts-without-any-plugin.html</link>
		<comments>http://wpfunc.com/wordpress/popular-posts-without-any-plugin.html#comments</comments>
		<pubDate>Sat, 25 Jul 2009 08:25:14 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[Popular Posts]]></category>
		<category><![CDATA[sidebar]]></category>
		<category><![CDATA[single.php]]></category>
		<category><![CDATA[Widget]]></category>

		<guid isPermaLink="false">http://www.wpfunc.com/?p=110</guid>
		<description><![CDATA[Hi everybody, you can show your most commented popular posts wtihout any plugin. It&#8217;s a simple code. Easy useable and appliable. We will edit siderbar.php or single.php. Where you want to show popular posts, you can edit any file. If you are ready, Lets begin&#8230; Here is the code; If you want to make a [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Hi everybody, you can show your most commented popular posts wtihout any plugin. It&#8217;s a simple code. Easy useable and appliable. We will edit siderbar.php or single.php. Where you want to show popular posts, you can edit any file. If you are ready, Lets begin&#8230;<span id="more-110"></span></p>
<h3>Here is the code;</h3>
<pre class="brush: plain; title: ; notranslate">&lt;h2&gt;Popular Posts&lt;/h2&gt;
&lt;ul&gt;
&lt;?php $result = $wpdb-&gt;get_results(&quot;SELECT comment_count,ID,post_title FROM $wpdb-&gt;posts ORDER BY comment_count DESC LIMIT 0 , 5&quot;);
foreach ($result as $post) {
setup_postdata($post);
$postid = $post-&gt;ID;
$title = $post-&gt;post_title;
$commentcount = $post-&gt;comment_count;
if ($commentcount != 0) { ?&gt;
&lt;li&gt;&lt;a href=&quot;&lt;?php echo get_permalink($postid); ?&gt;&quot; title=&quot;&lt;?php echo $title ?&gt;&quot;&gt;
&lt;?php echo $title ?&gt;&lt;/a&gt; {&lt;?php echo $commentcount ?&gt;}&lt;/li&gt;
&lt;?php } } ?&gt;
&lt;/ul&gt;</pre>
<p style="text-align: justify;">If you want to make a <em><strong>Popular Post Widget,</strong></em> you can use this code on <span style="color: #ff0000;"><em><strong>sidebar.php</strong></em></span> or if you want to show this after post, you have to add this code after loop in  <span style="color: #ff0000;"><strong><em>single.php</em></strong></span>.</p>
<p style="text-align: justify;">If you change the number &#8220;<em><strong>5</strong></em>&#8221; you can change Popular Posts Number :)</p>
<p style="text-align: justify;">That&#8217;s All! Have a nice day.</p>
]]></content:encoded>
			<wfw:commentRss>http://wpfunc.com/wordpress/popular-posts-without-any-plugin.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Use Two or More Single.php</title>
		<link>http://wpfunc.com/wordpress/use-two-or-more-single-php.html</link>
		<comments>http://wpfunc.com/wordpress/use-two-or-more-single-php.html#comments</comments>
		<pubDate>Thu, 16 Jul 2009 23:32:55 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[categories]]></category>
		<category><![CDATA[core file]]></category>
		<category><![CDATA[else]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[if]]></category>
		<category><![CDATA[single.php]]></category>
		<category><![CDATA[vectorss]]></category>

		<guid isPermaLink="false">http://www.wpfunc.com/?p=19</guid>
		<description><![CDATA[In WordPress, we can use only one single.php. But sometimes we need different single pages for different categories. Also my friend Hakan needs 2 different single.php for his site. We build a blog page for his Vectorss site but we had a problem with ads and published pictures. We have to change this single pages. [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">In WordPress, we can use only one single.php. But sometimes we need different single pages for different categories. Also my friend Hakan needs 2 different single.php for his site. We build a blog page for his <a href="http://www.vectorss.com" target="_blank">Vectorss</a> site but we had a problem with ads and published pictures. We have to change this single pages. After this problem, i was search and found a litte information about this problem. In this information there is a sentence like this &#8220;<em>You can solve this problem with if and else</em>&#8220;. I think about this  and i write some function. It&#8217;s Worked!<span id="more-19"></span><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>
<h3 style="text-align: justify;">Yep, lets start!</h3>
<p style="text-align: justify;">We cnahge our core single.php also you have to make a back-up this file. And you have to make 2 copy of this core file,  and <em><strong>single-blog.php</strong><strong>single-default.php</strong></em> (<em>single-default is a copy of our core file</em>). And upload these 2 files to your host (in template folder). After that, open your single.php on your server (with a ftp program ex: CuteFtp) and clean all code in this file and add this codes to single.php ;</p>
<pre class="brush: plain; title: ; notranslate">
&lt;?php
$post = $wp_query-&gt;post;
if ( in_category('3') ) {
 include(TEMPLATEPATH . '/single-blog.php'); }
 else { include(TEMPLATEPATH . '/single-default.php');
}
?&gt;</pre>
<p style="text-align: justify;">We make a duplicate with this code. But we give a special command to this code. With If, we said to code &#8220;<em>if we click a post in category 3 you have to call single-blog.php to us</em>&#8220;. If we get a normal category post, our core single.php call single-default.php to us. After this code our core single.php will be a tunnel page for us.</p>
<p style="text-align: justify;">And if you wanna make more single pages for your different categories you can duplicate this code.</p>
<h3>Here is the second code:</h3>
<pre class="brush: plain; title: ; notranslate">&lt;?php
$post = $wp_query-&gt;post;
if ( in_category('3') ) {
include(TEMPLATEPATH . '/single-blog.php'); }
elseif ( in_category('15') ) {
include(TEMPLATEPATH . '/single-foto.php'); }
elseif ( in_category('18') ) {
include(TEMPLATEPATH . '/single-video.php'); }
else { include(TEMPLATEPATH . '/single-default.php');
}
?&gt;</pre>
<p>Have a nice day!</p>
]]></content:encoded>
			<wfw:commentRss>http://wpfunc.com/wordpress/use-two-or-more-single-php.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

