<?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>The WordPress Guru &#187; Page</title>
	<atom:link href="http://wpguru.co.za/category/page/feed/" rel="self" type="application/rss+xml" />
	<link>http://wpguru.co.za</link>
	<description>Tips &#38; Pointers on Making a Killer CMS with WordPress</description>
	<lastBuildDate>Mon, 01 Aug 2011 10:26:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Force a file to download</title>
		<link>http://wpguru.co.za/templates/page/force-a-file-to-download/</link>
		<comments>http://wpguru.co.za/templates/page/force-a-file-to-download/#comments</comments>
		<pubDate>Tue, 04 May 2010 08:42:54 +0000</pubDate>
		<dc:creator>MarkB</dc:creator>
				<category><![CDATA[Advanced]]></category>
		<category><![CDATA[Page]]></category>
		<category><![CDATA[Single]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://wpguru.co.za/?p=168</guid>
		<description><![CDATA[In building CMS sites for clients, some may require that you offer certain files to be downloaded off their site. A PDF for example, or perhaps wallpapers or other media. Most browsers, correctly, will display these items inline as a new page or tab however for these purposes you need to force the browser to [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_169" class="wp-caption alignright" style="width: 310px"><img class="size-medium wp-image-169" title="download" src="http://wpguru.co.za/wp-content/uploads/download-300x199.jpg" alt="" width="300" height="199" /><p class="wp-caption-text">Image by: vizzzual-dot-com</p></div>
<p>In building CMS sites for clients, some may require that you offer certain files to be downloaded off their site. A PDF for example, or perhaps wallpapers or other media. Most browsers, correctly, will display these items inline as a new page or tab however for these purposes you need to force the browser to download the item, not display it. Here&#8217;s how it&#8217;s done.</p>
<h3>The Code</h3>
<p>Your .htaccess file is the key to getting this done, and here&#8217;s the code you need to add:</p>
<pre class="brush: xml; title: ; notranslate">AddType application/octet-stream .csv
AddType application/octet-stream .xls
AddType application/octet-stream .doc
AddType application/octet-stream .avi
AddType application/octet-stream .mpg
AddType application/octet-stream .mov
AddType application/octet-stream .pdf</pre>
<p>You can of course add as many other filetypes to this list as you may require, but you can get the principle from this example.</p>
]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.za/templates/page/force-a-file-to-download/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Controlling the visibility of content with custom fields</title>
		<link>http://wpguru.co.za/templates/page/controlling-the-visibility-of-content-with-custom-fields/</link>
		<comments>http://wpguru.co.za/templates/page/controlling-the-visibility-of-content-with-custom-fields/#comments</comments>
		<pubDate>Fri, 05 Sep 2008 07:47:56 +0000</pubDate>
		<dc:creator>MarkB</dc:creator>
				<category><![CDATA[Page]]></category>
		<category><![CDATA[content]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[custom fields]]></category>

		<guid isPermaLink="false">http://wpguru.co.za/?p=78</guid>
		<description><![CDATA[I've just finished a project for a client who wanted an interesting feature on his site. He wanted a block of content to be turned on and off whenever he needed it. So when he wanted to promote something, he wanted to add some content and have it display until he was ready to 'turn it off'. I came up with a unique means of doing this using custom fields. Here's how you can achieve this:]]></description>
			<content:encoded><![CDATA[<div id="attachment_161" class="wp-caption alignright" style="width: 310px"><img class="size-medium wp-image-161" title="Custom Fields" src="http://wpguru.co.za/wp-content/uploads/customfields-300x200.jpg" alt="" width="300" height="200" /><p class="wp-caption-text">Image by: dcdead</p></div>
<p>I’ve just finished a project for a client who wanted an interesting feature on his site. He wanted a block of content to be turned on and off whenever he needed it. So when he wanted to promote something, he wanted to add some content and have it display until he was ready to ‘turn it off’. I came up with a unique means of doing this using custom fields. Here’s how you can achieve this:</p>
<h3>The Content</h3>
<p>Firstly create your page in WordPress that you’ll use as your toggle-able content page. Add your title and content and then add a custom field like active and set the value to yes.</p>
<p>SIDENOTE: It might be a good idea to set the slug of this page to something generic like /info/. This way, if the content has a ‘Read More’ link of sorts, the client wont have to continually change the slug each time he changes the title of this content area.</p>
<p>Now you’re done in the WP Admin, now you can get into your WP PHP template file where this toggle-able content will display.</p>
<h3>The Functionality</h3>
<p>Basically what you’re going to create, is a code snippet that will query the page ID of the page you created above, but before displaying the content of that page, it’ll check if the custom field value is set to yes. If it’s not, then no content will display, if its set to yes, then… well you can guess what’ll happen <img src='http://wpguru.co.za/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>The Code</h3>
<pre class="brush: php; title: ; notranslate">&lt;? if (get_post_meta(73, 'active', true) == &quot;yes&quot;) { ?&gt;
&lt;? query_posts('page_id=73'); if (have_posts()) : while (have_posts()) : the_post(); ?&gt;
	&lt;h3&gt;&lt;? the_title(); ?&gt;&lt;/h3&gt;
	&lt;? the_content(); ?&gt;
&lt;? endwhile; endif; wp_reset_query(); ?&gt;
&lt;? } ?&gt;</pre>
<p>And that’s that. It’s a pretty simple trick and you should be able to apply the principle to a number of circumstances.</p>
]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.za/templates/page/controlling-the-visibility-of-content-with-custom-fields/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Custom header images for WordPress Pages</title>
		<link>http://wpguru.co.za/header/custom-header-images-for-wordpress-pages/</link>
		<comments>http://wpguru.co.za/header/custom-header-images-for-wordpress-pages/#comments</comments>
		<pubDate>Mon, 18 Aug 2008 12:27:53 +0000</pubDate>
		<dc:creator>MarkB</dc:creator>
				<category><![CDATA[Header]]></category>
		<category><![CDATA[Page]]></category>
		<category><![CDATA[Single]]></category>
		<category><![CDATA[Styling]]></category>
		<category><![CDATA[Admin]]></category>
		<category><![CDATA[custom field]]></category>
		<category><![CDATA[custom header]]></category>
		<category><![CDATA[image]]></category>

		<guid isPermaLink="false">http://wpguru.co.za/?p=72</guid>
		<description><![CDATA[I've had a recent request regarding a popular tweak for WordPress - that is, to add custom page header images to any page in WordPress. There are one or two plugins that do this, but with a bit of creativity you can accomplish this very easily using WordPress custom fields and it's built in image uploader. Here's how:]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve had a <a href="http://www.jasonbagley.com/">recent request</a> regarding a popular tweak for WordPress &#8211; that is, to add custom page header images to any page in WordPress. There are one or two plugins that do this, but with a bit of creativity you can accomplish this very easily using WordPress custom fields and it&#8217;s built in image uploader. Here&#8217;s how:</p>
<h3>The basics</h3>
<p>You&#8217;re basically going to setup a number of if/else statements in your template where you want your header image to appear. The final statement will be an else statement so that if none of the above rules apply, it&#8217;ll degrade so that you&#8217;ll always have a header image on your page.</p>
<p>You&#8217;re going to create a custom field that has the name of the image that you want to use as a header image. You don&#8217;t have to add the full path to the image. Since you&#8217;re uploading your custom image in the WordPress uploader, it&#8217;ll always end up in the same folder and so the path to the image will be entered in the template.</p>
<h3>The how-to</h3>
<p>So firstly create your image, and upload it to your page.</p>
<p>Then add a custom field called &#8220;header&#8221; and put the name of the file as the value of the field.</p>
<p><img class="aligncenter size-full wp-image-71" title="customfield1" src="http://wpguru.co.za/wp-content/uploads/customfield1.jpg" alt="" width="500" height="194" /></p>
<p>Then open up your template where you want your image to appear and add the following PHP &#8211; tailored to work as you need it to&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>get_post_meta<span style="color: #009900;">&#40;</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;">'header'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
	&lt;img src=&quot;<span style="color: #000000; font-weight: bold;">&lt;?</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>/wp-content/uploads/<span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #b1b100;">echo</span> get_post_meta<span style="color: #009900;">&#40;</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;">'header'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; alt=&quot;<span style="color: #000000; font-weight: bold;">&lt;?</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>&quot; /&gt;
<span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
	&lt;img src=&quot;<span style="color: #000000; font-weight: bold;">&lt;?</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>/images/header.jpg&quot; /&gt;
<span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>So what you&#8217;ve now done, is tell the template to check if the custom field &#8220;header&#8221; has a value. If it does, then use that value to display your image. However, if the custom field is empty, then it&#8217;ll degrade to the second default image that you specify.</p>
<p>And presto: you can now use your WP admin to control header images on each page. This is also a good way to do it because now your client can update/add his header images on his own without having to bug you.</p>
]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.za/header/custom-header-images-for-wordpress-pages/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
		<item>
		<title>Creating a Static WordPress Front Page</title>
		<link>http://wpguru.co.za/templates/page/creating-a-static-wordpress-front-page/</link>
		<comments>http://wpguru.co.za/templates/page/creating-a-static-wordpress-front-page/#comments</comments>
		<pubDate>Thu, 19 Jun 2008 08:57:46 +0000</pubDate>
		<dc:creator>MarkB</dc:creator>
				<category><![CDATA[Page]]></category>
		<category><![CDATA[cms]]></category>
		<category><![CDATA[front page]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[query posts]]></category>
		<category><![CDATA[static]]></category>

		<guid isPermaLink="false">http://wpguru.co.za/?p=65</guid>
		<description><![CDATA[This is far from a difficult thing to do. It's actually so easy, its ridiculous. But I see so many people installing plugins and doing really complicated page template hacks to get this right, that I think a post dedicated to this is justified. Here's the 30 second trick to getting a static front page.
]]></description>
			<content:encoded><![CDATA[<p>This is far from a difficult thing to do. It&#8217;s actually so easy, its ridiculous. But I see so many people installing plugins and doing really complicated page template hacks to get this right, that I think a post dedicated to this is justified. Here&#8217;s the 30 second trick to getting a static front page.</p>
<p>Every theme will have an index.php file. The <code>index.php</code> file is your home page. This page will have your loop, that will most often bring in your latest posts etc.</p>
<p>Find this line:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</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: #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></pre></div></div>

<p>and just above it add this line:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span> query_posts<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'page_id=5'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Note that &#8217;5&#8242; can be changed to whatever page you want to be your home page.</p>
<p>What this does, is generate a specific query that the following loop will carry out. In this case, it will call the content from <code>post_id=5</code>.</p>
<p>Bear in mind that if you have a dynamic WP page list, you&#8217;ll probably want to exclude the page you created to be your home page from your normal page list. You can do this by adding the exclude argument to your page list call. Like so:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span> wp_list_pages<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'title_li=&amp;sort_column=menu_order&amp;exclude=5'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>And presto, you have a static front page.</p>
]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.za/templates/page/creating-a-static-wordpress-front-page/feed/</wfw:commentRss>
		<slash:comments>44</slash:comments>
		</item>
		<item>
		<title>More creative uses for custom fields</title>
		<link>http://wpguru.co.za/templates/page/more-creative-uses-for-custom-fields/</link>
		<comments>http://wpguru.co.za/templates/page/more-creative-uses-for-custom-fields/#comments</comments>
		<pubDate>Thu, 10 Apr 2008 10:58:17 +0000</pubDate>
		<dc:creator>MarkB</dc:creator>
				<category><![CDATA[Page]]></category>
		<category><![CDATA[Single]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[custom fields]]></category>

		<guid isPermaLink="false">http://wpguru.co.za/?p=29</guid>
		<description><![CDATA[So your client has a small area of their site that displays their contact numbers. It's one of those small features that most sites have, but its also a feature that you don't want to be bugged with when it changes or when they need something edited. Here's a simple guide to how you can use custom fields for this.]]></description>
			<content:encoded><![CDATA[<p>So your client has a small area of their site that displays their contact numbers. It&#8217;s one of those small features that most sites have, but its also a feature that you don&#8217;t want to be bugged with when it changes or when they need something edited. Here&#8217;s a simple guide to how you can use custom fields for this.</p>
<p>Choose a page on their site that you know will be kept throughout the life of their site &#8211; Perhaps an &#8216;about us&#8217; page. Create custom fields for each of their contact details, maybe:</p>
<ul>
<li>Telephone: 012 345 6789</li>
<li>Fax: 012 345 6789</li>
<li>Email Address: info@site.com</li>
</ul>
<p>Then, use your special query to call the custom field for each of those</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;div id=&quot;contactdetails&quot;&gt;
	&lt;ul&gt;
		&lt;li&gt;Telephone: <span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #b1b100;">echo</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'telephone'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/li&gt;
		&lt;li&gt;Fax: <span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #b1b100;">echo</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'fax'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/li&gt;
		&lt;li&gt;Email: &lt;a href= &quot;mailto:<span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #b1b100;">echo</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'email'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #b1b100;">echo</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'email'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
&lt;/div&gt;</pre></div></div>

<p>Note that in this example, &#8217;2&#8242; is the <code>page_id</code> of the about us page. Change this number to whatever the ID is of the page that you use to keep this information.</p>
]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.za/templates/page/more-creative-uses-for-custom-fields/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Controlling custom content areas on your site</title>
		<link>http://wpguru.co.za/templates/page/controlling-custom-content-areas-on-your-site/</link>
		<comments>http://wpguru.co.za/templates/page/controlling-custom-content-areas-on-your-site/#comments</comments>
		<pubDate>Wed, 09 Apr 2008 07:27:57 +0000</pubDate>
		<dc:creator>MarkB</dc:creator>
				<category><![CDATA[Page]]></category>
		<category><![CDATA[content]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[query posts]]></category>

		<guid isPermaLink="false">http://wpguru.co.za/?p=25</guid>
		<description><![CDATA[Most of the time when you're designing a home page for a CMS based website, you're going to have specific areas of content on your page that aren't blog related, but that you want your client to have control over. For example their contact details, an 'about us' blurb, their company motto or maybe their company's vision. There exists a really easy way in WordPress to allow for these areas to be controlled through your admin. Here's how...]]></description>
			<content:encoded><![CDATA[<p>Most of the time when you&#8217;re designing a home page for a CMS based website, you&#8217;re going to have specific areas of content on your page that aren&#8217;t blog related, but that you want your client to have control over. For example their contact details, an &#8216;about us&#8217; blurb, their company motto or maybe their company&#8217;s vision. There exists a really easy way in WordPress to allow for these areas to be controlled through your admin.</p>
<p><a href="http://wpguru.co.za/wp-content/uploads/content.gif"><img class="alignnone size-full wp-image-23" title="content" src="http://wpguru.co.za/wp-content/uploads/content.gif" alt="" width="579" height="209" /></a></p>
<p>As the above example shows, we have a &#8216;Projects&#8217; area as well as a &#8216;random quote&#8217; area to the right. These actually 2 ways that you can accomplish this &#8211; either as a page or as a post.</p>
<p>First question you&#8217;d need to ask is, &#8220;Is that content area going to change often, or will it remain mostly static?&#8221; In the case of the former, your best best would be to accomplish this as a blog post.</p>
<h3>Using blog posts</h3>
<p>Firstly, create a category that will be used for entering these random quotes. If you do not want this information to form part of your company blog etc, then you&#8217;ll want to exclude that particular category from your normal listings. This can be done by simply adding <code>&#038;exclude=9</code> to your WordPress category query.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span> wp_list_cats<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'sort_column=name&amp;optioncount=0&amp;exclude=9'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Then on your page where you want this information to appear, you&#8217;d call it like this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span> query_posts<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'cat=9&amp;showposts=1'</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;?</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: #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>
&lt;!-- LOOP STUFF HERE --&gt;
<span style="color: #000000; font-weight: bold;">&lt;?</span> <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>

<p>Additionally, you can also add <code>orderby=rand()</code> to bring in a random quote on each page reload.</p>
<h3>Using pages</h3>
<p>If however, the content you&#8217;re wanting to display will hardly change, like a company vision statement or contact details, then you can simply create a custom loop that brings in the content from that 1 specific page.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span> query_posts<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'page_id=2'</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;?</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: #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>
&lt;!-- LOOP STUFF HERE --&gt;
<span style="color: #000000; font-weight: bold;">&lt;?</span> <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>

<p>In this way, you&#8217;ll display just that particular content area and your or your client will be able to update this information as &amp; when they need to.</p>
]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.za/templates/page/controlling-custom-content-areas-on-your-site/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How to make good use of custom fields</title>
		<link>http://wpguru.co.za/templates/page/how-to-make-good-use-of-custom-fields/</link>
		<comments>http://wpguru.co.za/templates/page/how-to-make-good-use-of-custom-fields/#comments</comments>
		<pubDate>Tue, 08 Apr 2008 15:28:57 +0000</pubDate>
		<dc:creator>MarkB</dc:creator>
				<category><![CDATA[Page]]></category>
		<category><![CDATA[Single]]></category>
		<category><![CDATA[custom fields]]></category>
		<category><![CDATA[images]]></category>

		<guid isPermaLink="false">http://wpguru.co.za/?p=14</guid>
		<description><![CDATA[WordPress' custom fields are an often overlooked feature that gives an amazing boost of power to your content management system. Custom fields allow you to take your WordPress installation from a simple post and page management tool, to a full database management system. Here's how...]]></description>
			<content:encoded><![CDATA[<p>WordPress&#8217; custom fields are an often overlooked feature that gives an amazing boost of power to your content management system. Custom fields allow you to take your WordPress installation from a simple post and page management tool, to a full database management system. Here&#8217;s how&#8230;</p>
<h3>What are they?</h3>
<p><a href="http://wpguru.co.za/wp-admin/WordPress' custom fields are an often overlooked feature that gives an amazing boost of power to your content management system. Custom fields allow you to take your WordPress installation from a simple post and page management tool, to a full database management system. Here's how..." target="_blank">Custom fields</a> are essentially extra fields attached to a post. There&#8217;s the <strong>key</strong> which is the &#8216;name&#8217; of your extra field. Then there&#8217;s <strong>value</strong> which is pretty self explanatory &#8211; its the value of the key that you&#8217;ve inserted. You can add any number of values to one specific key, and you can add as many key/value combinations as you like.</p>
<h3>Ways of using Custom Fields</h3>
<p>Lets say that you&#8217;re starting an accommodation listing site, and you have 3 or 4 images for each listing that you&#8217;d like to show.</p>
<ul>
<li>Upload the first image</li>
<li>Enter the key &#8216;images&#8217;</li>
<li>Paste the path to the uploaded image as the value of this key</li>
<li>&#8216;Add Custom Field&#8217;</li>
<li>Repeat as many times as necessary</li>
</ul>
<p>Now you have an array of values assigned to the key &#8216;images&#8217;. Now in your <code>single.php</code> template, you want to show these images. No problems. What you&#8217;re going to do, is create a loop that will repeat for as many images as you&#8217;ve uploaded. Like so:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #000088;">$images</span> <span style="color: #339933;">=</span> get_post_meta<span style="color: #009900;">&#40;</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;">&quot;images&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</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;?</span> <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$images</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$image</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;img src=<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$image</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span> /&gt;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Alternatively, lets say that you want to have a thumbnail for each entry in your <code>archive.php</code> template. You can combine some crafty CSS with a PHP query to bring in 1 of the images in the &#8216;images&#8217; array and presto!</p>
<p>Here&#8217;s how to display your image:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;div class=&quot;thumb&quot;&gt;
	&lt;a href= &quot;<span style="color: #000000; font-weight: bold;">&lt;?</span><span style="color: #339933;">&amp;</span>phpMyAdmin<span style="color: #339933;">=</span>01d7dd3a1764f33b9145cd20ad99db24 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; title=&quot;<span style="color: #000000; font-weight: bold;">&lt;?</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>&quot;&gt;&lt;img src=&quot;<span style="color: #000000; font-weight: bold;">&lt;?</span> <span style="color: #b1b100;">echo</span> get_post_meta<span style="color: #009900;">&#40;</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;">'images'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; alt=&quot;<span style="color: #000000; font-weight: bold;">&lt;?</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>&quot; /&gt;&lt;/a&gt;
&lt;/div&gt;</pre></div></div>

<p>*NOTE: The alt tag uses <code>the_title()</code> function which will name your image according to the page/post that its on.</p>
<p>and the CSS:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.thumb</span> <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">80px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">80px</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>The CSS is required because the image that you uploaded is probably larger than what you&#8217;d want as a thumbnail. So the overflow:hidden command in the div thats wrapping the image will cut if off to a size that&#8217;ll suit you better.</p>
]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.za/templates/page/how-to-make-good-use-of-custom-fields/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Display title &amp; excerpt of child pages</title>
		<link>http://wpguru.co.za/templates/page/display-title-excerpt-of-child-pages/</link>
		<comments>http://wpguru.co.za/templates/page/display-title-excerpt-of-child-pages/#comments</comments>
		<pubDate>Tue, 08 Apr 2008 12:56:45 +0000</pubDate>
		<dc:creator>MarkB</dc:creator>
				<category><![CDATA[Page]]></category>
		<category><![CDATA[conditional tags]]></category>
		<category><![CDATA[dynamic]]></category>
		<category><![CDATA[excerpt]]></category>

		<guid isPermaLink="false">http://wpguru.co.za/?p=10</guid>
		<description><![CDATA[When you're actively using the page hierarchy in WordPress, many times you'll create a parent page simply so that you can create the sub pages. For example, a page called Team might only be created so that you can have Joe Soap and Jane Doe as sub pages. There's no real content to be put on that parent page, because the child pages are where the real information lies.]]></description>
			<content:encoded><![CDATA[<div id="attachment_157" class="wp-caption alignright" style="width: 310px"><img class="size-medium wp-image-157" title="WordPress Pages" src="http://wpguru.co.za/wp-content/uploads/pages1-300x225.jpg" alt="" width="300" height="225" /><p class="wp-caption-text">Image by: moonjazz</p></div>
<p>When you’re actively using the page hierarchy in WordPress, many times you’ll create a parent page simply so that you can create the sub pages. For example, a page called Team might only be created so that you can have <strong>Joe Soap</strong> and <strong>Jane Doe</strong> as sub pages. There’s no real content to be put on that parent page, because the child pages are where the real information lies.</p>
<p>Instead of simply typing “Click the links to the left” and leaving the page largely empty, you can create a dynamic page template that will display a title and excerpt for each of the child pages.</p>
<p>You can do this by inserting this below the main loop of your page.php file.</p>
<pre class="brush: php; title: ; notranslate">&lt;? $pageChildren = $wpdb-&gt;get_results(&quot;SELECT * FROM $wpdb-&gt;posts WHERE post_parent = &quot;.$post-&gt;ID.&quot; AND post_type = 'page' ORDER BY menu_order&quot;, 'OBJECT');	?&gt;
&lt;? if ( $pageChildren ) : foreach ( $pageChildren as $pageChild ) : setup_postdata( $pageChild ); ?&gt;
&lt;!-- loop stuff here --&gt;
&lt;? endforeach; endif; ?&gt;</pre>
<p>In cases where you actually do have content for your parent page and you don’t want to display this title/excerpt setup, then you can make use of conditional tags to exclude the posts where you don’t want this to happen. For example:</p>
<pre class="brush: php; title: ; notranslate">&lt;? if (is_page('3')) { } else { // if its page 3 then show nothing ?&gt;
&lt;? $pageChildren = $wpdb-&gt;get_results(&quot;SELECT * FROM $wpdb-&gt;posts WHERE post_parent = &quot;.$post-&gt;ID.&quot; AND post_type = 'page' ORDER BY menu_order&quot;, 'OBJECT'); ?&gt;
&lt;? if ( $pageChildren ) : foreach ( $pageChildren as $pageChild ) : setup_postdata( $pageChild ); ?&gt;
&lt;!-- loop stuff here --&gt;
&lt;? endforeach; endif; } ?&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://wpguru.co.za/templates/page/display-title-excerpt-of-child-pages/feed/</wfw:commentRss>
		<slash:comments>49</slash:comments>
		</item>
	</channel>
</rss>

