<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Code Wordpress</title>
	
	<link>http://codewordpress.com</link>
	<description>Code and Snippets for Wordpress</description>
	<lastBuildDate>Sat, 21 Nov 2009 02:32:28 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/CodeWordpress" /><feedburner:info uri="codewordpress" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Automatically Get Images on Post Content</title>
		<link>http://feedproxy.google.com/~r/CodeWordpress/~3/8Qyi8ok4Y-I/automatically-get-images-on-post-content</link>
		<comments>http://codewordpress.com/wordpress-images/automatically-get-images-on-post-content#comments</comments>
		<pubDate>Sat, 21 Nov 2009 02:32:28 +0000</pubDate>
		<dc:creator>thinkclay</dc:creator>
				<category><![CDATA[Wordpress Images]]></category>
		<category><![CDATA[custom fields]]></category>
		<category><![CDATA[custom function]]></category>

		<guid isPermaLink="false">http://codewordpress.com/?p=51</guid>
		<description><![CDATA[The problem. Using custom fields to display images associated with your post is definitely a great idea, but many WordPress users would like a solution for retrieving images embedded in the post’s content itself.
The solution. As far as we know, there’s no plug-in to do that. Happily, the following loop will do the job: it [...]]]></description>
			<content:encoded><![CDATA[<p><strong>The problem</strong>. Using custom fields to display images associated with your post is definitely a great idea, but many WordPress users would like a solution for retrieving images embedded in the post’s content itself.</p>
<p><strong>The solution</strong>. As far as we know, there’s no plug-in to do that. Happily, the following loop will do the job: it searches for images in post content and displays them on the screen.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> the_post<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$szPostContent</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_content</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$szSearchPattern</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'~&lt;img [^\&gt;]*\ /&gt;~'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Run preg_match_all to grab all the images and save the results in $aPics</span>
<span style="color: #990000;">preg_match_all</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$szSearchPattern</span><span style="color: #339933;">,</span> <span style="color: #000088;">$szPostContent</span><span style="color: #339933;">,</span> <span style="color: #000088;">$aPics</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Check to see if we have at least 1 image</span>
<span style="color: #000088;">$iNumberOfPics</span> <span style="color: #339933;">=</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$aPics</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$iNumberOfPics</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #666666; font-style: italic;">// Now here you would do whatever you need to do with the images</span>
 <span style="color: #666666; font-style: italic;">// For this example the images are just displayed</span>
 <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$iNumberOfPics</span> <span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$aPics</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<img src="http://feeds.feedburner.com/~r/CodeWordpress/~4/8Qyi8ok4Y-I" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://codewordpress.com/wordpress-images/automatically-get-images-on-post-content/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://codewordpress.com/wordpress-images/automatically-get-images-on-post-content</feedburner:origLink></item>
		<item>
		<title>Wordpress Adsense Shortcode</title>
		<link>http://feedproxy.google.com/~r/CodeWordpress/~3/ZAcRbN3IX9c/wordpress-adsense-shortcode</link>
		<comments>http://codewordpress.com/wordpress-hack/wordpress-adsense-shortcode#comments</comments>
		<pubDate>Thu, 12 Nov 2009 03:53:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Wordpress Hack]]></category>
		<category><![CDATA[adsense]]></category>
		<category><![CDATA[custom function]]></category>
		<category><![CDATA[shortcode]]></category>

		<guid isPermaLink="false">http://codewordpress.com/?p=35</guid>
		<description><![CDATA[
function showads&#40;&#41; &#123;  
 return '&#60;div id=&#34;adsense&#34;&#62;&#60;script type=&#34;text/javascript&#34;&#62;&#60;!--  
 google_ad_client = &#34;pub-XXXXXXXXXXXXXX&#34;;  
 google_ad_slot = &#34;4668915978&#34;;  
 google_ad_width = 468;  
 google_ad_height = 60;  
 //--&#62;  
 &#60;/script&#62;  
&#160;
 &#60;script type=&#34;text/javascript&#34;  src=&#34;http://pagead2.googlesyndication.com/pagead/show_ads.js&#34;&#62;  
 &#60;/script&#62;&#60;/div&#62;';  
 &#125;  
&#160;
 add_shortcode&#40;'adsense', 'showads'&#41;;

]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> showads<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>  
 <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'&lt;div id=&quot;adsense&quot;&gt;&lt;script type=&quot;text/javascript&quot;&gt;&lt;!--  
 google_ad_client = &quot;pub-XXXXXXXXXXXXXX&quot;;  
 google_ad_slot = &quot;4668915978&quot;;  
 google_ad_width = 468;  
 google_ad_height = 60;  
 //--&gt;  
 &lt;/script&gt;  
&nbsp;
 &lt;script type=&quot;text/javascript&quot;  src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot;&gt;  
 &lt;/script&gt;&lt;/div&gt;'</span><span style="color: #339933;">;</span>  
 <span style="color: #009900;">&#125;</span>  
&nbsp;
 add_shortcode<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'adsense'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'showads'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<img src="http://feeds.feedburner.com/~r/CodeWordpress/~4/ZAcRbN3IX9c" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://codewordpress.com/wordpress-hack/wordpress-adsense-shortcode/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://codewordpress.com/wordpress-hack/wordpress-adsense-shortcode</feedburner:origLink></item>
		<item>
		<title>WordPress Bloginfo</title>
		<link>http://feedproxy.google.com/~r/CodeWordpress/~3/c32HOJB-VgM/wordpress-bloginfo</link>
		<comments>http://codewordpress.com/wordpress-code/wordpress-bloginfo#comments</comments>
		<pubDate>Mon, 09 Nov 2009 20:18:50 +0000</pubDate>
		<dc:creator>shanestrong05</dc:creator>
				<category><![CDATA[Wordpress Code]]></category>

		<guid isPermaLink="false">http://codewordpress.com/?p=26</guid>
		<description><![CDATA[
&#60;?php bloginfo&#40;'name'&#41;; ?&#62;  Blog Title
&#60;?php bloginfo&#40;'url'&#41;; ?&#62;  Base URL
&#60;?php bloginfo&#40;'template_directory'&#41;; ?&#62; Current active template directory
&#60;?php bloginfo&#40;'description'&#41;; ?&#62;  Blog description or tagline
&#60;?php bloginfo&#40;'admin_email'&#41;; ?&#62; admin email address
&#60;?php bloginfo&#40;'comments_atom_url'&#41;; ?&#62;  comments atom feed
&#60;?php bloginfo&#40;'comments_rss2_url'&#41;; ?&#62; comments rss2 feed
&#60;?php bloginfo&#40;'rdf_url'&#41;; ?&#62;  rdf feed
&#60;?php bloginfo&#40;'rss2_url'&#41;; ?&#62;  rss2 feed
&#60;?php bloginfo&#40;'rss_url'&#41;; ?&#62;  rss feed
&#60;?php [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>  Blog Title
<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>  Base URL
<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'template_directory'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> Current active template directory
<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'description'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>  Blog description or tagline
<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'admin_email'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> admin email address
<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'comments_atom_url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>  comments atom feed
<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'comments_rss2_url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> comments rss2 feed
<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'rdf_url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>  rdf feed
<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'rss2_url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>  rss2 feed
<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'rss_url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>  rss feed
<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'siteurl'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>  Home Page
<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'stylesheet_directory'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>  style sheet directory
<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'stylesheet_url'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> style sheet url
<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'version'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>  2.8.5
<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wpurl'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>  http://example/home/wp</pre></div></div>

<img src="http://feeds.feedburner.com/~r/CodeWordpress/~4/c32HOJB-VgM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://codewordpress.com/wordpress-code/wordpress-bloginfo/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://codewordpress.com/wordpress-code/wordpress-bloginfo</feedburner:origLink></item>
		<item>
		<title>Display Random Posts in Wordpress</title>
		<link>http://feedproxy.google.com/~r/CodeWordpress/~3/4RlQiwUowfI/display-random-posts-in-wordpress</link>
		<comments>http://codewordpress.com/wordpress-hack/display-random-posts-in-wordpress#comments</comments>
		<pubDate>Sun, 08 Nov 2009 07:31:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Wordpress Hack]]></category>

		<guid isPermaLink="false">http://codewordpress.com/?p=24</guid>
		<description><![CDATA[
&#60;ul&#62;
&#60;?php
$rand_posts = get_posts&#40;'numberposts=10&#38;orderby=rand'&#41;;
foreach&#40; $rand_posts as $post &#41; :
?&#62;
&#60;li&#62;&#60;a href=&#34;&#60;?php the_permalink&#40;&#41;; ?&#62;&#34;&#62;
&#60;?php the_title&#40;&#41;; ?&#62;
&#60;/a&#62;
&#60;?php the_time&#40;'M d Y'&#41;; ?&#62;
&#60;/li&#62;
&#60;?php endforeach; ?&#62;
&#60;/a&#62;
&#60;/ul&#62;

]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;ul&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$rand_posts</span> <span style="color: #339933;">=</span> get_posts<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'numberposts=10&amp;orderby=rand'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$rand_posts</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$post</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;li&gt;&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_permalink<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/a&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_time<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'M d Y'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/li&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endforeach</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/a&gt;
&lt;/ul&gt;</pre></div></div>

<img src="http://feeds.feedburner.com/~r/CodeWordpress/~4/4RlQiwUowfI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://codewordpress.com/wordpress-hack/display-random-posts-in-wordpress/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://codewordpress.com/wordpress-hack/display-random-posts-in-wordpress</feedburner:origLink></item>
		<item>
		<title>Display Random Images from Media Gallery</title>
		<link>http://feedproxy.google.com/~r/CodeWordpress/~3/oHqZES1Me6o/display-random-images-from-media-gallery</link>
		<comments>http://codewordpress.com/wordpress-hack/display-random-images-from-media-gallery#comments</comments>
		<pubDate>Sun, 08 Nov 2009 07:01:05 +0000</pubDate>
		<dc:creator>thinkclay</dc:creator>
				<category><![CDATA[Wordpress Hack]]></category>
		<category><![CDATA[media gallery]]></category>

		<guid isPermaLink="false">http://codewordpress.com/?p=21</guid>
		<description><![CDATA[
&#60;?php
$args = array&#40;
'post_type' =&#62; 'attachment',
'numberposts' =&#62; -1,
'post_status' =&#62; null,
'post_parent' =&#62; $post-&#62;ID,
'orderby' =&#62; 'rand'
&#41;;
$attachments = get_posts&#40;$args&#41;;
$noimages = count&#40;$attachments&#41;;
&#160;
if &#40;$attachments&#41; &#123;
&#160;
foreach &#40;$attachments as $attachment&#41; &#123;
$alttxt = $attachment-&#62;post_title;
$imgid = $attachment-&#62;ID;
$fileurl = $attachment-&#62;guid;
&#160;
$meta = wp_get_attachment_metadata&#40;$imgid&#41;;
$imgw = $meta&#91;'sizes'&#93;&#91;'thumbnail'&#93;&#91;'width'&#93;;
$imgh = $meta&#91;'sizes'&#93;&#91;'thumbnail'&#93;&#91;'height'&#93;;
&#160;
$imgext = substr&#40;$fileurl, -4&#41;;
$fileurl = substr&#40;$fileurl, 0, -4&#41;;
$fileurl = $fileurl.&#34;-&#34;.$imgw.&#34;x&#34;.$imgh.$imgext;
&#160;
// construct the image
echo &#34;&#60;img src='&#34;.$fileurl.&#34;' alt='&#34;.$alttxt.&#34;' class='alignleft highlightimg' /&#62;&#34;;
break;
&#125;
&#125;
the_excerpt&#40;''&#41;;
?&#62;

]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$args</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
<span style="color: #0000ff;">'post_type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'attachment'</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'numberposts'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'post_status'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'post_parent'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span>
<span style="color: #0000ff;">'orderby'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'rand'</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$attachments</span> <span style="color: #339933;">=</span> get_posts<span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$noimages</span> <span style="color: #339933;">=</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$attachments</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$attachments</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$attachments</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$attachment</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$alttxt</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$attachment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_title</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$imgid</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$attachment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$fileurl</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$attachment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">guid</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$meta</span> <span style="color: #339933;">=</span> wp_get_attachment_metadata<span style="color: #009900;">&#40;</span><span style="color: #000088;">$imgid</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$imgw</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$meta</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'sizes'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'thumbnail'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'width'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$imgh</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$meta</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'sizes'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'thumbnail'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'height'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$imgext</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fileurl</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$fileurl</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fileurl</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$fileurl</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$fileurl</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$imgw</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;x&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$imgh</span><span style="color: #339933;">.</span><span style="color: #000088;">$imgext</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// construct the image</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;img src='&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$fileurl</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;' alt='&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$alttxt</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;' class='alignleft highlightimg' /&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
the_excerpt<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<img src="http://feeds.feedburner.com/~r/CodeWordpress/~4/oHqZES1Me6o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://codewordpress.com/wordpress-hack/display-random-images-from-media-gallery/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://codewordpress.com/wordpress-hack/display-random-images-from-media-gallery</feedburner:origLink></item>
		<item>
		<title>Display Subpage Nav in Wordpress</title>
		<link>http://feedproxy.google.com/~r/CodeWordpress/~3/XMzzXRCpSKk/display-subpage-nav-in-wordpress</link>
		<comments>http://codewordpress.com/wordpress-navigation/display-subpage-nav-in-wordpress#comments</comments>
		<pubDate>Sat, 07 Nov 2009 05:17:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Wordpress Navigation]]></category>

		<guid isPermaLink="false">http://codewordpress.com/?p=17</guid>
		<description><![CDATA[
&#60;?php
$children = wp_list_pages&#40;'title_li=&#38;child_of='.$post-&#62;ID.'&#38;echo=0'&#41;;
if &#40;$children&#41; &#123; ?&#62;
&#60;?php echo $children; ?&#62;
&#60;?php &#125; ?&#62;

]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$children</span> <span style="color: #339933;">=</span> wp_list_pages<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'title_li=&amp;child_of='</span><span style="color: #339933;">.</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;echo=0'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$children</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$children</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<img src="http://feeds.feedburner.com/~r/CodeWordpress/~4/XMzzXRCpSKk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://codewordpress.com/wordpress-navigation/display-subpage-nav-in-wordpress/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://codewordpress.com/wordpress-navigation/display-subpage-nav-in-wordpress</feedburner:origLink></item>
		<item>
		<title>Dynamic Title in Wordpress</title>
		<link>http://feedproxy.google.com/~r/CodeWordpress/~3/XJn-fPmm9Xc/dynamic-title-in-wordpress</link>
		<comments>http://codewordpress.com/wordpress-seo/dynamic-title-in-wordpress#comments</comments>
		<pubDate>Sat, 07 Nov 2009 04:30:59 +0000</pubDate>
		<dc:creator>thinkclay</dc:creator>
				<category><![CDATA[Wordpress SEO]]></category>
		<category><![CDATA[seo]]></category>
		<category><![CDATA[title tag]]></category>

		<guid isPermaLink="false">http://codewordpress.com/?p=13</guid>
		<description><![CDATA[If you&#8217;re not interested in changing your title tags on a post-to-post basis, then this is a good solution to show relevant titles to the page that the user is on.

&#60;title&#62;
&#60;?php
if &#40;is_home&#40;&#41;&#41; &#123;
echo bloginfo&#40;'name'&#41;;
&#125; elseif &#40;is_404&#40;&#41;&#41; &#123;
echo '404 Not Found';
&#125; elseif &#40;is_category&#40;&#41;&#41; &#123;
echo 'Category:'; wp_title&#40;''&#41;;
&#125; elseif &#40;is_search&#40;&#41;&#41; &#123;
echo 'Search Results';
&#125; elseif &#40; is_day&#40;&#41; &#124;&#124; is_month&#40;&#41; [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re not interested in changing your title tags on a post-to-post basis, then this is a good solution to show relevant titles to the page that the user is on.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;title&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_home<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span>is_404<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'404 Not Found'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span>is_category<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Category:'</span><span style="color: #339933;">;</span> wp_title<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span>is_search<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Search Results'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span> is_day<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> is_month<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> is_year<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Archives:'</span><span style="color: #339933;">;</span> wp_title<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> wp_title<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/title&gt;</pre></div></div>

<img src="http://feeds.feedburner.com/~r/CodeWordpress/~4/XJn-fPmm9Xc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://codewordpress.com/wordpress-seo/dynamic-title-in-wordpress/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://codewordpress.com/wordpress-seo/dynamic-title-in-wordpress</feedburner:origLink></item>
	</channel>
</rss>
