<?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>Pingable :: Everything Wordpress &#187; PHP</title>
	<atom:link href="http://www.pingable.org/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pingable.org</link>
	<description>Just another WordPress site</description>
	<lastBuildDate>Tue, 24 Jan 2012 00:32:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>5 WordPress PHP Code Snippets</title>
		<link>http://www.pingable.org/5-wordpress-php-code-snippets/</link>
		<comments>http://www.pingable.org/5-wordpress-php-code-snippets/#comments</comments>
		<pubDate>Thu, 03 Jan 2008 02:00:14 +0000</pubDate>
		<dc:creator>Simon Ward</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Lists]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Snippet]]></category>

		<guid isPermaLink="false">http://www.pingable.org/5-wordpress-php-code-snippets/</guid>
		<description><![CDATA[Assign an image to post ID This snip assigns an image to each unique post ID from WordPress, which in this case I have made a gif. If you put a file in the image folder in your root directory of your WordPress install called 8.gif &#8211; the 8th post you made on your blog [...]]]></description>
			<content:encoded><![CDATA[<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="standard" count="1" href="http://www.pingable.org/5-wordpress-php-code-snippets/"></g:plusone></div><h4><strong>Assign an image to post ID</strong></h4>
<p>This snip assigns an image to each unique post ID from WordPress, which in this case I have made a gif. If you put a file in the image folder in your root directory of your WordPress install called 8.gif &#8211; the 8th post you made on your blog will be assigned that image wherever you place this code. If there is no image for that id (you haven’t put a file called 8.gif in yet) it assigns the image called logo.gif. You can change any of the directories, file extensions, and the alternative image name to suit your own needs. You can find the post ID by looking in manage posts from your dash. You should use this code in template files. </p>
<p>&lt;?php&nbsp; <br />$image = “$id.gif”; <br />if(is_readable(“./images/$image”))&nbsp; <br />{ <br />echo “&lt;img src=’/images/$image’ alt=’alt tag’&nbsp; /&gt;”;&nbsp; <br />}&nbsp; <br />else&nbsp; <br />{&nbsp; <br />echo “&lt;img src=’/images/logo.gif’ alt=’alt tag’ /&gt;”;&nbsp; <br />}&nbsp; <br />?&gt;</p>
<p> <span id="more-88"></span><br />
<h4><a href="http://www.problogdesign.com/how-to/separating-trackbacks-from-comments/"><strong>To Separate the Trackbacks</strong></a><strong> </strong></h4>
<p>Open <em>comments.php</em>, and search for the following line:
<p><code>&lt;?php foreach ($comments as $comment) : ?&gt;</code>
<p>After it, paste the following:
<p><code>&lt;?php $comment_type = get_comment_type(); ?&gt;<br />&lt;?php if($comment_type == 'comment') { ?&gt;</code>
<p>Now look for:
<p><code>&lt;?php endforeach; /* end for each comment */ ?&gt;</code>
<p>And before it, paste:
<p><code>&lt;?php } /* End of is_comment statement */ ?&gt;</code>
<p>This will display your comments without any trackbacks or pingbacks. To add a second <em>comments loop</em> for the trackbacks.
<p>Look for the following line:
<p><code>&lt;?php else : // this is displayed if there are no comments so far ?&gt;</code>
<p>And before it, paste this:
<p><code>&lt;h3&gt;Trackbacks&lt;/h3&gt;<br />&lt;ol&gt;<br />&lt;?php foreach ($comments as $comment) : ?&gt;<br />&lt;?php $comment_type = get_comment_type(); ?&gt;<br />&lt;?php if($comment_type != 'comment') { ?&gt;<br />&lt;li&gt;&lt;?php comment_author_link() ?&gt;&lt;/li&gt;<br />&lt;?php } ?&gt;<br />&lt;?php endforeach; ?&gt;<br />&lt;/ol&gt;</code></p>
<h4><a href="http://snipplr.com/view/4151/grab-category-name/"><strong>Grab Category Name</strong></a></h4>
<p>This PHP snippet will get the category of the current post and place it in line where the code is inserted. It would be useful to add a heading or phrase that relates to the category. </p>
<p>&lt;? $cat = get_the_category(); $cat = $cat[0]; echo $cat-&gt;cat_name;?&gt;</p>
<h4><strong>Dynamic List That Pulls The Most Recent Posts</strong></h4>
<p>A WordPress function often used in sidebars that displays the most recent posts as a list. Replace 3 with how many items you want in your list.
<p>&lt;?php get_archives(&#8216;postbypost&#8217;, 3); ?&gt;<br />
<h4><a href="http://max.limpag.com/2006/04/08/pieces-of-wordpress-theme-code-a-repository/"><strong>Make Your WordPress Header Image Clickable</strong></a></h4>
<p>Replace the starting div tag for the header with this:</p>
<p><code>&lt;div id="header" onclick="location.href='http://www.pingable.org/';" style="cursor: pointer;"&gt;</code>
<p align="right"><img alt="www.pingable.org" src="http://www.pingable.org/images/sig.gif"></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pingable.org/5-wordpress-php-code-snippets/feed/</wfw:commentRss>
		<slash:comments>33</slash:comments>
		</item>
		<item>
		<title>WordPress PHP Code Snip &#8211; Assign image to post ID</title>
		<link>http://www.pingable.org/wordpress-php-code-snip-assign-image-to-post-id/</link>
		<comments>http://www.pingable.org/wordpress-php-code-snip-assign-image-to-post-id/#comments</comments>
		<pubDate>Sun, 01 Jul 2007 07:42:14 +0000</pubDate>
		<dc:creator>Simon Ward</dc:creator>
				<category><![CDATA[Blogging Tips]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Images]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.pingable.org/wordpress-php-code-snip-assign-image-to-post-id/</guid>
		<description><![CDATA[The following PHP code is some code I use on this blog that I thought some others that don&#8217;t program may find useful. What it does is assign an image to each unique post ID from WordPress&#160;that is a gif file. If you put a file in&#160;the&#160;image folder in your root directory of your Website [...]]]></description>
			<content:encoded><![CDATA[<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="standard" count="1" href="http://www.pingable.org/wordpress-php-code-snip-assign-image-to-post-id/"></g:plusone></div><p>The following PHP code is some code I use on this blog that I thought some others that don&#8217;t program may find useful. What it does is assign an image to each unique post ID from WordPress&nbsp;that is a gif file. If you put a file in&nbsp;the&nbsp;image folder in your root directory of your Website called 8.gif &#8211; the 8th post you made on your blog will be assigned that image wherever you place this code.&nbsp;If there is no image for that id (you haven&#8217;t&nbsp;put a file called 8.gif in yet)&nbsp;it assigns the image called uplogo.gif. <a href="http://www.uberpiglet.com/category/blogging/">Demo. </a>Of course you can change any of the directories, file extensions, and the alternative image name&nbsp;to suit your own needs.You can find the post ID by looking in manage posts from your dash. You should use this code in template files.</p>
<div class="csharpcode">
<pre class="alt">&lt;?php  </pre>
<pre>$image = <span class="str">"$id.gif"</span>; </pre>
<pre class="alt"><span class="kwrd">if</span>(is_readable(<span class="str">"./images/$image"</span>))  </pre>
<pre>{ </pre>
<pre class="alt">echo <span class="str">"&lt;img src='/images/$image' alt='alt tag'  /&gt;"</span>;  </pre>
<pre>}  </pre>
<pre class="alt"><span class="kwrd">else</span>  </pre>
<pre>{  </pre>
<pre class="alt">echo <span class="str">"&lt;img src='/images/uplogo.gif' alt='alt tag' /&gt;"</span>;  </pre>
<pre>}  </pre>
<pre class="alt">?&gt;</pre>
</div>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<p>
<p>Check out some other WordPress hacks: <a href="http://www.thepinkc.net/wordpress/stop-using-wordpress-plugins-top-3-wordpress-hacks/">WordPress hacks</a></p>
<p align="right"><img alt="www.pingable.org" src="http://www.pingable.org/images/sig.gif"></p>
]]></content:encoded>
			<wfw:commentRss>http://www.pingable.org/wordpress-php-code-snip-assign-image-to-post-id/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
	</channel>
</rss>

