<?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>Mortfiles Evolved &#187; custom fields</title>
	<atom:link href="http://mortfiles.com/evolved/tag/custom-fields/feed/" rel="self" type="application/rss+xml" />
	<link>http://mortfiles.com/evolved</link>
	<description></description>
	<lastBuildDate>Thu, 23 Jul 2009 07:00:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Going wordpress mu</title>
		<link>http://mortfiles.com/evolved/development/going-wordpress-mu/</link>
		<comments>http://mortfiles.com/evolved/development/going-wordpress-mu/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 13:27:04 +0000</pubDate>
		<dc:creator>Jimi Wikman</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[custom fields]]></category>
		<category><![CDATA[faq]]></category>
		<category><![CDATA[jquery ui]]></category>
		<category><![CDATA[wordpress mu]]></category>

		<guid isPermaLink="false">http://mortfiles.com/evolved/?p=67</guid>
		<description><![CDATA[After some toying this weekend I have decided to go for a setup using Wordpress mu, the Wordpress multiblogsystem. 
There are many reasons for choosing Wordpress mu and for me the biggest reasons was that it will allow me better flexibility, more focused plugin usage to avoid speed degradation and the fact that it will [...]]]></description>
			<content:encoded><![CDATA[<p><strong>After some toying this weekend I have decided to go for a setup using Wordpress mu, the Wordpress multiblogsystem. </strong></p>
<p>There are many reasons for choosing Wordpress mu and for me the biggest reasons was that it will allow me better flexibility, more focused plugin usage to avoid speed degradation and the fact that it will make my life a whole lot easier. The fact that I can later plugin community functions are just the icing on the cake <img src='http://mortfiles.com/evolved/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>My first step will be to install Wordpress mu and setup the Main blog area to be the entrypage and then transfer the Support area so I can redirect my clients  there. The support area will actually be the most blog-heavy area of the website where I look forward to building the entire FAQ using Wordpress mu. This will be a truly versatile FAQ database indeed where I will take good use of the many possibilities of Wordpress.</p>
<p>Once the entry page and support area is complete I&#8217;ll start working on the main blog again to build up the bulk of the website using pages and posts side by side with the use of <a href="http://mortfiles.com/evolved/development/working-with-custom-fields/">custom fields</a> if things work out as planned. The thought is to add custom fields to each page where I can input the ID of posts I want included in a section that is tabbed up using Jquery UI. That way I can manage all content separate, which is a bit like I have worked before with include files&#8230;but now it will be so much easier to manage!</p>
<p>After that I will setup my blog again and &#8220;simply&#8221; import all the data from the old database and work with that a bit. I will rework the blog a bit to make it easier to work with for me and to leave room for outside participation&#8230;I&#8217;ll write more about that later. The reason for adding the blog before I add things like the portfolio is that I have a serious itch about writing!</p>
<p>After the blog I will add the Portfolio and then the company section before I start pondering on other things. I have some scetchy plans about adding a dedicated downloads section and a blog just for status about the hosting to make them independent and easy to manage. I also have thoughts about setting up a forum (ipb) and use that for authentication purposes, but I am not sure&#8230;maybe I&#8217;ll just stick with bbpress which ties in well with Buddypress that is the next step (maybe) or skip it alltogether&#8230;we&#8217;ll see how that evolve.</p>
]]></content:encoded>
			<wfw:commentRss>http://mortfiles.com/evolved/development/going-wordpress-mu/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Working with custom fields</title>
		<link>http://mortfiles.com/evolved/development/working-with-custom-fields/</link>
		<comments>http://mortfiles.com/evolved/development/working-with-custom-fields/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 13:03:52 +0000</pubDate>
		<dc:creator>Jimi Wikman</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[custom fields]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://mortfiles.com/evolved/?p=62</guid>
		<description><![CDATA[How to use Wordpress customfields is always useful to know and I found this on the very informative website perishablepress.com, so all credit to them for putting this together!
Source: http://perishablepress.com/press/2008/12/22/wordpress-custom-fields-tips-tricks/
Display values of a specific key
To loop through and display the values of a specific key, place the following within the loop of your choice, and [...]]]></description>
			<content:encoded><![CDATA[<p>How to use Wordpress customfields is always useful to know and I found this on the very informative website perishablepress.com, so all credit to them for putting this together!</p>
<p>Source: <a href="http://perishablepress.com/press/2008/12/22/wordpress-custom-fields-tips-tricks/">http://perishablepress.com/press/2008/12/22/wordpress-custom-fields-tips-tricks/</a></p>
<h3>Display values of a specific key</h3>
<p>To loop through and display the values of a specific key, place the following within the loop of your choice, and change the “<code>mood</code>” value to that of your desired key value:</p>
<p><code>&lt;?php echo get_post_meta($post-&gt;ID, 'mood', true); ?&gt;</code></p>
<h3>Display multiple values of a specific key</h3>
<p><span id="more-62"></span></p>
<p>Each custom-field key may include multiple values. For example, if you listen to multiple songs during a given post, you may want to list them all with a key of “<code>songs</code>”. Then to loop through and display the multiple values for the <code>songs</code> key, we place the following code into the loop of choice:</p>
<pre><code>&lt;?php $songs = get_post_meta($post-&gt;ID, 'songs', false); ?&gt;
	&lt;h3&gt;This post inspired by:&lt;/h3&gt;
	&lt;ul&gt;
		&lt;?php foreach($songs as $song) {
			echo '&lt;li&gt;'.$song.'&lt;/li&gt;';
			} ?&gt;
	&lt;/ul&gt;</code></pre>
<p>Notice the trick here: by changing the third parameter to “<code>false</code>”, we tell the function to return an array of the values for the specified key. A very handy trick for displaying multiple key values.</p>
<h3>Display content only if a custom field exists</h3>
<p>For cases when not all posts contain some specific custom-field key, use the following code to prevent unwanted, empty or incomplete markup from destroying the validity of your page:</p>
<pre><code>// display an image based on custom-field value, if it exists

&lt;?php $image = get_post_meta($post-&gt;ID, 'url', true);

	if($image) : ?&gt;

	&lt;img src="&lt;?php echo $image; ?&gt;" alt="" /&gt;

	&lt;?php endif; ?&gt;</code></pre>
<h3>Conditional display of custom-field data</h3>
<p>Continuing with the previous technique, here is a basic code template for displaying a list of key values only if they exist:</p>
<pre><code>&lt;?php if(get_post_meta($post-&gt;ID, 'books', true) ||
	 get_post_meta($post-&gt;ID, 'music', true) ||
	 get_post_meta($post-&gt;ID, 'sites', true)
	 ): ?&gt;

	&lt;ul&gt;
		&lt;?php if(get_post_meta($post-&gt;ID, 'books', true)): ?&gt;
		&lt;li&gt;&lt;?php echo get_post_meta($post-&gt;ID, 'books', true); ?&gt;&lt;/li&gt;
		&lt;?php endif; ?&gt;

		&lt;?php if(get_post_meta($post-&gt;ID, 'music', true)): ?&gt;
		&lt;li&gt;&lt;?php echo get_post_meta($post-&gt;ID, 'music', true); ?&gt;&lt;/li&gt;
		&lt;?php endif; ?&gt;

		&lt;?php if(get_post_meta($post-&gt;ID, 'sites', true)): ?&gt;
		&lt;li&gt;&lt;?php echo get_post_meta($post-&gt;ID, 'sites', true); ?&gt;&lt;/li&gt;
		&lt;?php endif; ?&gt;
	&lt;/ul&gt;

&lt;?php endif; ?&gt;</code></pre>
<h3>More conditional content based on custom-field values</h3>
<p>Here’s another neat trick whereby custom-field values are used to determine which type of content appears on a page. In this example, we are checking the value of of a custom-field key called “<code>hobbies</code>”. Depending on the value of the <code>hobbies</code> key, different links are output on the page. Check it out:</p>
<pre><code>&lt;?php $value = get_post_meta($post-&gt;ID, 'hobbies', true);

	if($value == 'gaming') {
		echo '&lt;a href="http://domain.tld/gaming/"&gt;Gaming Stuff&lt;/a&gt;';
	} elseif($value == 'sleeping') {
		echo '&lt;a href="http://domain.tld/sleeping/"&gt;Nap Supplies&lt;/a&gt;';
	} elseif($value == 'eating') {
		echo '&lt;a href="http://domain.tld/eating/"&gt;Dieting Advice&lt;/a&gt;';
	} else {
		echo '&lt;a href="http://domain.tld/"&gt;Home Page&lt;/a&gt;';
	}

?&gt;</code></pre>
<h3>Simplification and externalization</h3>
<p>To clean up our source code a little, we can relocate the <code>get_post_meta()</code> function to the theme’s <code>functions.php</code> file. The immediate benefit here is one less parameter to include in the template tag. To do this, first place the following code into your theme’s <code>functions.php</code> file:</p>
<pre><code>&lt;?php function get_custom_field_data($key, $echo = false) {
	global $post;
	$value = get_post_meta($post-&gt;ID, $key, true);
	if($echo == false) {
		return $value;
	} else {
		echo $value;
	}
}
?&gt;</code></pre>
<p>..and then call the function by placing this code in the desired location within your page template:</p>
<pre><code>&lt;?php if(function_exists('get_custom_field_data')) {
	get_custom_field_data('key', true);
} ?&gt;</code></pre>
<p>The only thing you need to edit here is the value of the “<code>key</code>” parameter, which should be the same as the key for which you would like to display value data. The second parameter is currently set as “<code>true</code>” so that the key value is echoed to the browser. To save the key value as a variable for further processing, change this parameter to “<code>false</code>”.</p>
]]></content:encoded>
			<wfw:commentRss>http://mortfiles.com/evolved/development/working-with-custom-fields/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
