<?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>wpCanyon</title>
	<atom:link href="http://wpcanyon.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://wpcanyon.com</link>
	<description>Wordpress tutorials, articles, hacks, tricks and many more</description>
	<lastBuildDate>Thu, 22 Jul 2010 16:19:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Why Don&#8217;t You Let People See The Options Panel Demo</title>
		<link>http://wpcanyon.com/articles/why-dont-you-let-people-see-the-options-panel-demo/</link>
		<comments>http://wpcanyon.com/articles/why-dont-you-let-people-see-the-options-panel-demo/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 18:27:15 +0000</pubDate>
		<dc:creator>Boba</dc:creator>
				<category><![CDATA[Articles]]></category>

		<guid isPermaLink="false">http://wpcanyon.com/?p=733</guid>
		<description><![CDATA[Noticed how not a single premium WordPress themes seller allow you to give the options panel a try and see the full potential of a theme. Well here is a little idea that might change that.]]></description>
			<content:encoded><![CDATA[<p><img src="http://wpcanyon.com/wp-content/uploads/2010/07/optionspanelpic1.png" alt="" title="optionspanelpic" width="600" height="100" class="alignnone size-full wp-image-741" /></p>
<p>One very important aspect of a premium WordPress theme is the flexibility it offers to the users. That flexibility comes from the theme&#8217;s options panel. Some themes have ten options and some even have hundreds. But why doesn&#8217;t anyone allow the potential buyers to try the options out, make changes and see the full demonstration of a theme they are about to buy, not even WooThemes does that.</p>
<h2>Why?</h2>
<p>Well it&#8217;s quite simple, every time someone makes a change it will overwrite someone else&#8217;s changes and there is a big possibility that more people will be testing the options out at the same time and keep overwriting each other&#8217;s changes and wouldn&#8217;t be able to see how it works and behaves properly thus confusing everybody.</p>
<p>You probably have a blog, do you? Well imagine few more people making changes to it at the same time as you do, it&#8217;s like that. Stuff changes and you have no idea why, you didn&#8217;t change it. </p>
<h2>So, How?</h2>
<p>Well the idea is pretty simple, if you&#8217;re a theme/plugin developer you know that we have to add a prefix to our field names that go inside the database in order to avoid conflicts with other themes/plugins that could use the same names. For example, an option where the user inputs text he wants to be shown in the footer of a theme, we can call it &#8220;footer_text&#8221; but then it might conflict, so we add a prefix like &#8220;wpcp_&#8221;, &#8220;aviatic_&#8221; or anything else that we think should be unique or at least unlikely to be used by something else, so we get wpcp_footer_text. </p>
<p>Using that same method we can add the username of the user that makes changes as a suffix or prefix (doesn&#8217;t matter) so if a user with username &#8220;John&#8221; makes changes they will be saved and later retrieved as &#8220;wpcp_footer_text_John&#8221; and when a different user with username &#8220;Michael&#8221; makes changes it will be &#8220;wpcp_footer_text_Michael&#8221; so no conflicts will be made and no data will be overwritten.</p>
<h2>Database Usage</h2>
<p>For themes that have a big amount of options (like WooThemes or PliablePress) it will use a lot of data. For example 50 options changed by 100 users is 5000 rows in the database. But that&#8217;s not a big problem because WordPress can be set to delete the data after a certain time period.</p>
<h2>Does It Really Work?</h2>
<p>Well in theory it should work just fine, it&#8217;s pretty simple, i haven&#8217;t tested it yet but i started working on a little example and will update this post when it&#8217;s done. In the meantime if anybody is reading this let me know your thoughts.</p>
<h2>Update: It Works</h2>
<p>I just tested it and it works without a problem. I needed 2 minutes to alter a theme to support this, yes just 2 minutes, few lines of code. Check back later, i&#8217;ll throw in a demo so you can all test it out.</p>
]]></content:encoded>
			<wfw:commentRss>http://wpcanyon.com/articles/why-dont-you-let-people-see-the-options-panel-demo/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Increasing The Categories Selection Height In WordPress Admin</title>
		<link>http://wpcanyon.com/tipsandtricks/increasing-the-categories-selection-height-in-wordpress-admin/</link>
		<comments>http://wpcanyon.com/tipsandtricks/increasing-the-categories-selection-height-in-wordpress-admin/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 10:46:51 +0000</pubDate>
		<dc:creator>Boba</dc:creator>
				<category><![CDATA[Tips&Tricks]]></category>

		<guid isPermaLink="false">http://wpcanyon.com/?p=727</guid>
		<description><![CDATA[Increasing the height of the categories selection listing in WordPress admin using 2 different methods, CSS and jQuery. ]]></description>
			<content:encoded><![CDATA[<p>Few days ago a loyal reader (thx Sullivan) asked how to increase the height of the categories listing in WordPress admin since he has a lot of categories. If you wonder what categories listing it&#8217;s the one on the &#8220;add new post&#8221; page where you select which categories will the post be in (it&#8217;s also located on other places). </p>
<h2>CSS hack</h2>
<p>This hack is a simple CSS hack that allows you to change the height of the default 200px to a new fixed height.</p>
<pre class="brush: php;">
add_action('admin_head', 'categories_list_height_css');

function categories_list_height_css() {
	echo'
	&lt;style type=&quot;text/css&quot;&gt;
		#category-all.tabs-panel{ height:500px; }
	&lt;/style&gt;
	';
}
</pre>
<h2>jQuery hack</h2>
<p>This is a bit better hack because it will change the height dynamically to fit all the categories.</p>
<pre class="brush: php;">
add_action('admin_head', 'categories_list_height_jquery');

function categories_list_height_jquery() {
	echo'
	&lt;script type=&quot;text/javascript&quot;&gt;
		jQuery(function($){
			$(&quot;#category-all.tabs-panel&quot;).height($(&quot;#categorychecklist&quot;).height());
		});
	&lt;/script&gt;
	';
}
</pre>
<p>Both hacks go inside <strong>functions.php</strong> file inside your theme folder.</p>
]]></content:encoded>
			<wfw:commentRss>http://wpcanyon.com/tipsandtricks/increasing-the-categories-selection-height-in-wordpress-admin/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Show Top Commentators In WordPress Without A Plugin</title>
		<link>http://wpcanyon.com/tipsandtricks/show-top-commentators-in-wordpress-without-a-plugin/</link>
		<comments>http://wpcanyon.com/tipsandtricks/show-top-commentators-in-wordpress-without-a-plugin/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 14:36:56 +0000</pubDate>
		<dc:creator>Boba</dc:creator>
				<category><![CDATA[Tips&Tricks]]></category>

		<guid isPermaLink="false">http://wpcanyon.com/?p=716</guid>
		<description><![CDATA[Here is a simple code snippet for getting the top commentators listing in WordPress so you don't have to use a plugin for that purpose.]]></description>
			<content:encoded><![CDATA[<p>First put this snippet in your functions.php file inside your theme.</p>
<pre class="brush: php;">
function top_comment_authors($amount = 5){

	global $wpdb;

	$results = $wpdb-&gt;get_results('
		SELECT
			COUNT(comment_author_email) AS comments_count, comment_author_email, comment_author, comment_author_url
		FROM
			'.$wpdb-&gt;comments.'
		WHERE
			comment_author_email != &quot;&quot; AND comment_type = &quot;&quot; AND comment_approved = 1
		GROUP BY
			comment_author_email
		ORDER BY
			comments_count DESC, comment_author ASC
		LIMIT '.$amount

	);

	$output = &quot;&lt;ul&gt;&quot;;
	foreach($results as $result){
		$output .= &quot;&lt;li&gt;&quot;.$result-&gt;comment_author.&quot;&lt;/li&gt;&quot;;
	}
	$output .= &quot;&lt;/ul&gt;&quot;;

	echo $output;

}
</pre>
<p>Now you can call it anywhere in your theme using the <strong>top_comment_authors()</strong> function. By default it will show top 5 but if you want a different amount simply call it like <strong>top_comment_authors(7)</strong> which will show top 7 comment authors.</p>
<p>If you want to show more data in the listing you can use these:</p>
<ul>
<li><strong>$result->comment_author_email</strong> <em>the email address of the commentator</em></li>
<li><strong>$result->comments_count</strong> <em>comments number of the commentator</em></li>
<li><strong>$result->comment_author_url</strong> <em>the website address of the commentator</em></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://wpcanyon.com/tipsandtricks/show-top-commentators-in-wordpress-without-a-plugin/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Adding Classes To previous_posts_link() And next_posts_link() In WordPress</title>
		<link>http://wpcanyon.com/tipsandtricks/adding-attributes-to-previous-and-next-post-links/</link>
		<comments>http://wpcanyon.com/tipsandtricks/adding-attributes-to-previous-and-next-post-links/#comments</comments>
		<pubDate>Tue, 22 Jun 2010 10:04:29 +0000</pubDate>
		<dc:creator>Boba</dc:creator>
				<category><![CDATA[Tips&Tricks]]></category>

		<guid isPermaLink="false">http://wpcanyon.com/?p=690</guid>
		<description><![CDATA[Little snippet for adding classes and other attributes to previous_post_link() and next_post_link().]]></description>
			<content:encoded><![CDATA[<p>Simply insert the snippet bellow inside your theme&#8217;s function.php file.</p>
<pre class="brush: php;">
add_filter('next_posts_link_attributes', 'posts_link_attributes');
add_filter('previous_posts_link_attributes', 'posts_link_attributes');

function posts_link_attributes(){
	return 'class=&quot;styled-button&quot;';
}
</pre>
<p>What actually this snippet does is adding the html you return in the function to the anchor. </p>
<p>&lt;a href=&#8217;link&#8217; <strong>HERE</strong>&gt;</p>
<p>So you can add ID, classes and other attributes an anchor can have. By default it will only have the <strong>href</strong> attribute.</p>
]]></content:encoded>
			<wfw:commentRss>http://wpcanyon.com/tipsandtricks/adding-attributes-to-previous-and-next-post-links/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Best On WordPress From The Past Week N.10</title>
		<link>http://wpcanyon.com/roundups/best-on-wordpress-from-the-past-week-n-10/</link>
		<comments>http://wpcanyon.com/roundups/best-on-wordpress-from-the-past-week-n-10/#comments</comments>
		<pubDate>Tue, 15 Jun 2010 08:52:21 +0000</pubDate>
		<dc:creator>Boba</dc:creator>
				<category><![CDATA[Roundups]]></category>

		<guid isPermaLink="false">http://wpcanyon.com/?p=682</guid>
		<description><![CDATA[This is our weekly roundup of the best wordpress articles, tips, tricks and news from the past week we ware able to find on the web.]]></description>
			<content:encoded><![CDATA[<p>All of these were tweeted on our twitter account during the past week, so don&#8217;t forget to <a href='http://wpcanyon.com' target='_blank'>follow wpCanyon on twitter</a> for awesome wordpress related links.</p>
<h2><a href='http://www.yourinspirationweb.com/en/how-to-install-wordpress-locally/' target='_blank'>How to install WordPress Locally?</a></h2>
<p><a href='http://www.yourinspirationweb.com/en/how-to-install-wordpress-locally/' target='_blank'><img src='http://wpcanyon.com/post-images/topweek10/top1.png' alt='top' /></a></p>
<h2><a href='http://wpcanyon.com/tipsandtricks/adding-a-custom-field-automatically-on-postpage-publish/' target='_blank'>Adding A Custom Field Automatically On Post/Page Publish</a></h2>
<p><a href='http://wpcanyon.com/tipsandtricks/adding-a-custom-field-automatically-on-postpage-publish/' target='_blank'><img src='http://wpcanyon.com/post-images/topweek10/top2.png' alt='top' /></a></p>
<h2><a href='http://bavotasan.com/downloads/magazine-basic-free-wordpress-theme/' target='_blank'>Free Theme: Magazine Basic v2.6.1</a></h2>
<p><a href='http://bavotasan.com/downloads/magazine-basic-free-wordpress-theme/' target='_blank'><img src='http://wpcanyon.com/post-images/topweek10/top3.png' alt='top' /></a></p>
<h2><a href='http://wpengineer.com/flattr-button-4-wordpress-without-a-plugin/' target='_blank'>Flattr Button for WordPress without a Plugin</a></h2>
<p><a href='http://wpengineer.com/flattr-button-4-wordpress-without-a-plugin/' target='_blank'><img src='http://wpcanyon.com/post-images/topweek10/top4.png' alt='top' /></a></p>
<h2><a href='http://carsonified.com/blog/dev/20-must-have-wordpress-plugins-for-every-website/' target='_blank'>20 Must Have WordPress Plugins For Every Website</a></h2>
<p><a href='http://carsonified.com/blog/dev/20-must-have-wordpress-plugins-for-every-website/' target='_blank'><img src='http://wpcanyon.com/post-images/topweek10/top5.png' alt='top' /></a></p>
<h2><a href='http://justintadlock.com/archives/2010/06/10/a-refresher-on-custom-taxonomies' target='_blank'>A Refresher On Custom Taxonomies</a></h2>
<p><a href='http://justintadlock.com/archives/2010/06/10/a-refresher-on-custom-taxonomies' target='_blank'><img src='http://wpcanyon.com/post-images/topweek10/top6.png' alt='top' /></a></p>
<h2><a href='http://themethesis.com/resources/gravity-forms/' target='_blank'>5 Reasong Gravity Forms Makes Your From Plugin Look Like Crap</a></h2>
<p><a href='http://themethesis.com/resources/gravity-forms/' target='_blank'><img src='http://wpcanyon.com/post-images/topweek10/top7.png' alt='top' /></a></p>
<h2><a href='http://www.webdesignerdepot.com/2010/06/wordpress-from-kubrick-to-twenty-ten/' target='_blank'>WordPress: From Kubrick to Twenty Ten</a></h2>
<p><a href='http://www.webdesignerdepot.com/2010/06/wordpress-from-kubrick-to-twenty-ten/' target='_blank'><img src='http://wpcanyon.com/post-images/topweek10/top8.png' alt='top' /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://wpcanyon.com/roundups/best-on-wordpress-from-the-past-week-n-10/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Adding A Custom Field Automatically On Post/Page Publish</title>
		<link>http://wpcanyon.com/tipsandtricks/adding-a-custom-field-automatically-on-postpage-publish/</link>
		<comments>http://wpcanyon.com/tipsandtricks/adding-a-custom-field-automatically-on-postpage-publish/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 10:28:27 +0000</pubDate>
		<dc:creator>Boba</dc:creator>
				<category><![CDATA[Tips&Tricks]]></category>

		<guid isPermaLink="false">http://wpcanyon.com/?p=670</guid>
		<description><![CDATA[Little code snippet for automatically adding a custom field  for a page or post when they are published.]]></description>
			<content:encoded><![CDATA[<p>Simply add the code bellow in your <strong>functions.php</strong> file inside your theme&#8217;s folder. And don&#8217;t forget to change the custom field name.</p>
<pre class="brush: php;">
add_action('publish_page', 'add_custom_field_automatically');
add_action('publish_post', 'add_custom_field_automatically');
function add_custom_field_automatically($post_ID) {
	global $wpdb;
	if(!wp_is_post_revision($post_ID)) {
		add_post_meta($post_ID, 'field-name', 'custom value', true);
	}
}
</pre>
<p>That&#8217;s it. Hope this helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://wpcanyon.com/tipsandtricks/adding-a-custom-field-automatically-on-postpage-publish/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Best On WordPress From The Past Week N.9</title>
		<link>http://wpcanyon.com/roundups/best-on-wordpress-from-the-past-week-n-9/</link>
		<comments>http://wpcanyon.com/roundups/best-on-wordpress-from-the-past-week-n-9/#comments</comments>
		<pubDate>Mon, 07 Jun 2010 11:37:50 +0000</pubDate>
		<dc:creator>Boba</dc:creator>
				<category><![CDATA[Roundups]]></category>

		<guid isPermaLink="false">http://wpcanyon.com/?p=666</guid>
		<description><![CDATA[This is our weekly roundup of the best wordpress articles, tips, tricks and news from the past week we ware able to find on the web.]]></description>
			<content:encoded><![CDATA[<p>All of these were tweeted on our twitter account during the past week, so don&#8217;t forget to <a href='http://wpcanyon.com' target='_blank'>follow wpCanyon on twitter</a> for awesome wordpress related links.</p>
<h2><a href='http://www.deluxeblogtips.com/2010/05/add-custom-column.html' target='_blank'>Add Custom Column To WordPress Post Manage Page</a></h2>
<p><a href='http://www.deluxeblogtips.com/2010/05/add-custom-column.html' target='_blank'><img src='http://wpcanyon.com/post-images/topweek9/top1.png' alt='Add Custom Column To WordPress Post Manage Page' /></a></p>
<h2><a href='http://digwp.com/2010/05/wordpress-json-api-plugin/' target='_blank'>WordPress JSON API Plugin</a></h2>
<p><a href='http://digwp.com/2010/05/wordpress-json-api-plugin/' target='_blank'><img src='http://wpcanyon.com/post-images/topweek9/top2.png' alt='WordPress JSON API Plugin' /></a></p>
<h2><a href='http://net.tutsplus.com/tutorials/wordpress/your-first-wordpress-plugin-simple-optimization/' target='_blank'>Your First WordPress Plugin: Simple Optimization</a></h2>
<p><a href='http://net.tutsplus.com/tutorials/wordpress/your-first-wordpress-plugin-simple-optimization/' target='_blank'><img src='http://wpcanyon.com/post-images/topweek9/top3.png' alt='Your First WordPress Plugin: Simple Optimization' /></a></p>
<h2><a href='http://justintadlock.com/archives/2010/06/01/goodbye-headaches-hello-menus' target='_blank'>Goodbye, headaches. Hello, menus!</a></h2>
<p><a href='http://justintadlock.com/archives/2010/06/01/goodbye-headaches-hello-menus' target='_blank'><img src='http://wpcanyon.com/post-images/topweek9/top4.png' alt='Goodbye, headaches. Hello, menus!' /></a></p>
<h2><a href='http://blog.jilsonthomas.com/?p=4' target='_blank'>Free Theme: Jillz Theme</a></h2>
<p><a href='http://blog.jilsonthomas.com/?p=4' target='_blank'><img src='http://wpcanyon.com/post-images/topweek9/top5.png' alt='free theme' /></a></p>
<h2><a href='http://webdesignledger.com/tools/wordpress-3-0-changing-the-way-we-manage-content' target='_blank'>WordPress 3.0: Changing The Way We Manage Content</a></h2>
<p><a href='http://webdesignledger.com/tools/wordpress-3-0-changing-the-way-we-manage-content' target='_blank'><img src='http://wpcanyon.com/post-images/topweek9/top6.png' alt='WordPress 3.0: Changing The Way We Manage Content' /></a></p>
<h2><a href='http://www.onextrapixel.com/2010/05/31/a-complete-to-do-list-plugins-for-wordpress-site-maintenance/' target='_blank'>A Complete To-Do List &#038; Plugins for WordPress Site Maintenance</a></h2>
<p><a href='http://www.onextrapixel.com/2010/05/31/a-complete-to-do-list-plugins-for-wordpress-site-maintenance/' target='_blank'><img src='http://wpcanyon.com/post-images/topweek9/top7.png' alt='A Complete To-Do List &#038; Plugins for WordPress Site Maintenance' /></a></p>
<h2><a href='http://themethesis.com/tutorials/jquery-wordpress-archives/' target='_blank'>Create A Powerful jQuery-Powered Archives Page In WordPress</a></h2>
<p><a href='http://themethesis.com/tutorials/jquery-wordpress-archives/' target='_blank'><img src='http://wpcanyon.com/post-images/topweek9/top8.png' alt='Create A Powerful jQuery-Powered Archives Page In WordPress' /></a></p>
<h2><a href='http://www.smashingeeks.com/featured/wordpress-related-videos-at-present-on-youtube.html' target='_blank'>WordPress Related Videos At Present On Youtube</a></h2>
<p><a href='http://www.smashingeeks.com/featured/wordpress-related-videos-at-present-on-youtube.html' target='_blank'><img src='http://wpcanyon.com/post-images/topweek9/top9.png' alt='WordPress Related Videos At Present On Youtube' /></a></p>
<h2><a href='http://sixrevisions.com/wordpress/wordpress-theme-development-custom-versus-commercial/' target='_blank'>WordPress Theme Development: Custom versus Commercial</a></h2>
<p><a href='http://sixrevisions.com/wordpress/wordpress-theme-development-custom-versus-commercial/' target='_blank'><img src='http://wpcanyon.com/post-images/topweek9/top10.png' alt='WordPress Theme Development: Custom versus Commercial' /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://wpcanyon.com/roundups/best-on-wordpress-from-the-past-week-n-9/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Showing Amount Of Comments A Comment Author Made</title>
		<link>http://wpcanyon.com/tipsandtricks/showing-amount-of-comments-a-comment-author-made/</link>
		<comments>http://wpcanyon.com/tipsandtricks/showing-amount-of-comments-a-comment-author-made/#comments</comments>
		<pubDate>Fri, 04 Jun 2010 11:06:38 +0000</pubDate>
		<dc:creator>Boba</dc:creator>
				<category><![CDATA[Tips&Tricks]]></category>

		<guid isPermaLink="false">http://wpcanyon.com/?p=649</guid>
		<description><![CDATA[Little code snippet for showing amount of comment a comment author made. ]]></description>
			<content:encoded><![CDATA[<p>I saw a really cool thing on <a href='http://problogdesign.com'>ProBlogDesign</a>. In the comments there is also the amount of comments the comment authors made. Here is a screenshost.</p>
<p><img src="http://wpcanyon.com/wp-content/uploads/2010/06/problogdesign.png" alt="" title="problogdesign" width="600" height="165" class="alignnone size-full wp-image-650" /></p>
<p>Here is a function you can use to get and echo the number of comments a comment author made. Put it in the <strong>functions.php</strong> file in your theme.</p>
<pre class="brush: php;">
function commentCountAuthor(){

	$oneText = 'One comment';
	$moreText = '% comments';

	global $wpdb;

	$result = $wpdb-&gt;get_var('
		SELECT
			COUNT(comment_ID)
		FROM
			'.$wpdb-&gt;comments.'
		WHERE
			comment_author_email = &quot;'.get_comment_author_email().'&quot;'
	);

	if($result == 1): 

		echo str_replace('%', $result, $oneText);

	elseif($result &gt; 1): 

		echo str_replace('%', $result, $moreText);

	endif;

}
</pre>
<p>Simply call the functions inside the comments loop.</p>
<pre class="brush: php;">
commentCountAuthor();
</pre>
]]></content:encoded>
			<wfw:commentRss>http://wpcanyon.com/tipsandtricks/showing-amount-of-comments-a-comment-author-made/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Creating a Contact Page From Scratch in WordPress</title>
		<link>http://wpcanyon.com/tutorials/creating-a-contact-page-from-scratch-in-wordpress/</link>
		<comments>http://wpcanyon.com/tutorials/creating-a-contact-page-from-scratch-in-wordpress/#comments</comments>
		<pubDate>Wed, 02 Jun 2010 11:11:48 +0000</pubDate>
		<dc:creator>Boba</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://wpcanyon.com/?p=561</guid>
		<description><![CDATA[Step by step guide on building a contact page in WordPress using custom templates.]]></description>
			<content:encoded><![CDATA[<p>Well as the title says we are going to build a contact page in this tutorial. Nothing fancy, just the main stuff like:</p>
<ul>
<li>PHP validation</li>
<li>jQuery validation</li>
<li>AJAX submission (if javascript is turned off it will be submitted normally)</li>
</ul>
<p>We&#8217;re going to use WordPress custom template for this. Ready to get started? Just so you know, if you encounter any problems following this steps feel free to ask me about resolving them using the comment form and i&#8217;ll do my best to help you out.</p>
<h2>Step 1 &#8211; Creating the template</h2>
<p>First of all we need to create a custom template for our contact page. Simply create a new file in the theme folder, name it <strong>template-contact.php</strong> and add the code bellow.</p>
<pre class="brush: php;">
&lt;?php
/*
Template Name: Contact Form
*/
?&gt;
</pre>
<p>Now open up <strong>page.php</strong> file from your theme and copy the whole content after the code we just added. You should end up with something similar to the code bellow.</p>
<pre class="brush: php;">
&lt;?php
/*
Template Name: Contact Form
*/
?&gt;

&lt;?php get_header(); ?&gt;

	&lt;div id=&quot;main&quot;&gt;

		&lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt;

			&lt;div class=&quot;post&quot; id=&quot;post-&lt;?php the_ID(); ?&gt;&quot;&gt;

				&lt;h2&gt;&lt;?php the_title(); ?&gt;&lt;/h2&gt;

				&lt;div class=&quot;entry&quot;&gt;

					&lt;?php the_content(); ?&gt;

				&lt;/div&gt;

			&lt;/div&gt;

		&lt;?php endwhile; endif; ?&gt;

	&lt;/div&gt;

&lt;?php get_sidebar(); ?&gt;

&lt;?php get_footer(); ?&gt;
</pre>
<p>If you have more content then that don&#8217;t worry, it depends on the theme you&#8217;re currently using. If you are familiar with coding a WordPress theme then you can remove the comments part, but it&#8217;s not really necessary because you can disable commenting from inside the admin panel. </p>
<p>Now, if you take a look at the code bellow you will see where the rest of the code will go (the commented green colored parts)</p>
<pre class="brush: php; html-script: true;">
&lt;?php
/*
Template Name: Contact Form
*/
?&gt;

&lt;!-- PHP PART 1 GOES HERE (PROCESSING) --&gt;

&lt;?php get_header(); ?&gt;

&lt;!-- jQuery GOES HERE (VALIDATION AND AJAX PROCESSING) --&gt;

	&lt;div id=&quot;main&quot;&gt;

		&lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt;

			&lt;div class=&quot;post&quot; id=&quot;post-&lt;?php the_ID(); ?&gt;&quot;&gt;

				&lt;h2&gt;&lt;?php the_title(); ?&gt;&lt;/h2&gt;

				&lt;div class=&quot;entry&quot;&gt;

					&lt;?php the_content(); ?&gt;

				&lt;/div&gt;

			&lt;/div&gt;

		&lt;?php endwhile; endif; ?&gt;

		&lt;!-- CONTACT FORM HTML AND PHP PART 2 (MESSAGES) GOES HERE --&gt;

	&lt;/div&gt;

&lt;?php get_sidebar(); ?&gt;

&lt;?php get_footer(); ?&gt;
</pre>
<h2>Step 2 &#8211; HTML</h2>
<p>In this step we will create the form, just copy the snippet bellow in the place for the HTML part (as shown in the part 1).</p>
<pre class="brush: xml;">
&lt;div id=&quot;contact-form&quot;&gt;
	&lt;form action=&quot;&lt;?php the_permalink(); ?&gt;&quot; id=&quot;contact-form&quot; method=&quot;post&quot;&gt;

		&lt;p&gt;&lt;label for=&quot;c_name&quot;&gt;&lt;?php _e('Name') ?&gt;&lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;c_name&quot; id=&quot;c_name&quot; /&gt;&lt;/p&gt;

		&lt;p&gt;&lt;label for=&quot;c_email&quot;&gt;&lt;?php _e('Email') ?&gt;&lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;c_email&quot; id=&quot;c_email&quot; /&gt;&lt;/p&gt;

		&lt;p&gt;&lt;label for=&quot;c_subject&quot;&gt;&lt;?php _e('Subject') ?&gt;&lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;c_subject&quot; id=&quot;c_subject&quot; /&gt;&lt;/p&gt;

		&lt;p&gt;&lt;label for=&quot;c_message&quot;&gt;&lt;?php _e('Message') ?&gt;&lt;/label&gt; &lt;textarea name=&quot;c_message&quot; id=&quot;c_message&quot;&gt;&lt;/textarea&gt;&lt;/p&gt;

		&lt;p&gt;&lt;label for=&quot;c_submit&quot;&gt;&amp;nbsp;&lt;/label&gt; &lt;input type=&quot;submit&quot; name=&quot;c_submit&quot; id=&quot;c_submit&quot; /&gt;&lt;/p&gt;

		&lt;input type=&quot;hidden&quot; name=&quot;c_submitted&quot; id=&quot;c_submitted&quot; value=&quot;true&quot; /&gt;

	&lt;/form&gt;
&lt;/div&gt;
</pre>
<p>If you&#8217;re confused about where exactly to put it, then simply place it after the &#8220;loop&#8221; (&lt;?php endwhile; endif; ?&gt;), it&#8217;s important that it is in the same div as the div with class <em>&#8220;post&#8221;</em>. </p>
<h2>Step 3 &#8211; CSS</h2>
<p>We made the form, but it&#8217;s not really good looking so let&#8217;s add some simple styling. I commented some of the lines so it should be easy to understand what&#8217;s what. </p>
<p><em>Notice: The CSS goes in the style.css file, not inside the new template we created.</em></p>
<pre class="brush: css;">
#contact-form  label {
	display:block; /* needed in order to set a width */
	float:left; /* make it inline with the input field */
	width:100px;
}
#contact-form textarea {
	width:300px;
	height:80px;
}
#contact-form .error {
	margin-left:100px; /* same as label width */
	color: #9e2828;
}
</pre>
<p>Now it looks better, let&#8217;s move on.</p>
<h2>Step 4 &#8211; PHP</h2>
<p>The first chunk of code goes before the <em>&#8220;&lt;?php get_header(); ?&gt;&#8221;</em>.</p>
<pre class="brush: php;">
&lt;?php

$name_error = '';
$email_error = '';
$subject_error = '';
$message_error = '';

if($_REQUEST['c_submitted']){

	//check name
	if(trim($_REQUEST['c_name'] == &quot;&quot;)){
		//it's empty
		$name_error = __('You forgot to fill in your name');
		$error = true;
	}else{
		//its ok
		$c_name = trim($_REQUEST['c_name']);
	}

	//check email
	if(trim($_REQUEST['c_email'] === &quot;&quot;)){
		//it's empty
		$email_error = __('Your forgot to fill in your email address');
		$error = true;
	}else if(!eregi(&quot;^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$&quot;, trim($_REQUEST['c_email']))){
		//it's wrong format
		$email_error = __('Wrong email format');
		$error = true;
	}else{
		//it's ok
		$c_email = trim($_REQUEST['c_email']);
	}

	//check name
	if(trim($_REQUEST['c_subject'] === &quot;&quot;)){
		//it's empty
		$subject_error = __('You forgot to fill in the subject');
		$error = true;
	}else{
		//it's ok
		$c_subject = trim($_REQUEST['c_subject']);
	}

	//check name
	if(trim($_REQUEST['c_message'] === &quot;&quot;)){
		//it's empty
		$message_error = __('You forgot to fill in your name');
		$error = true;
	}else{
		//it's ok
		$c_message = trim($_REQUEST['c_message']);
	}

	//if no errors occured
	if($error != true) {

		$email_to = &quot;your_email_here@gmail.com&quot;; //change this with your email address
		$message_body = &quot;Name: $c_name \n\nEmail: $c_email \n\nComments: $c_message&quot;;
		$headers = &quot;From&quot;.get_bloginfo('title').' &lt;'.$emailTo.'&gt;' . &quot;\r\n&quot; .'Reply-To' . $email;

		mail($email_to, $c_subject, $message_body, $headers);

		$email_sent = true;
	}

}

?&gt;
</pre>
<p>It&#8217;s a big chunk of code but it&#8217;s really simple, first we validate the submitted data by checking if it&#8217;s empty and is the email correct. If it is empty or the email isn&#8217;t in the right format we set the <strong>&#8220;error&#8221;</strong> variable to true and the error messages so after finishing with the validation we can know what to do and let the user know too, submit or not. If the error variable is not set to true then we process with the emailing and if everything goes well we set up another variable, <strong>email_sent</strong>, to true so we know that the email is sent.</p>
<p><strong>Don&#8217;t forget to change the $email_to variable to your email address.</strong></p>
<p>In the second part of the PHP we are going to show the user if everything is correct, and if it&#8217;s not let him know what&#8217;s wrong. The new codes are mixing up with the previous coding so let&#8217;s take it slowly.</p>
<p>First of all when the contact email is successfully sent we don&#8217;t want to show the contact form, right? </p>
<pre class="brush: php;">
&lt;?php if(isset($email_sent) &amp;&amp; $email_sent == true){ ?&gt;

	&lt;p class=&quot;email-sent&quot;&gt;&lt;?php _e('Thank you for contacting. I will answer your email as soon as possible.') ?&gt;&lt;/p&gt;

&lt;?php }else{ ?&gt;

	&lt;div id=&quot;contact-form&quot;&gt;
		&lt;!-- the contact form --&gt;
	&lt;/div&gt;

&lt;?php } ?&gt;
</pre>
<p>Using a simple if/else check we are either gonna show the message for the successful contact or the contact form. The part inside the <strong>}else{</strong> and <strong>}</strong> is the contact form HTML, nothing new.</p>
<p>Now, it&#8217;s time for adding the code that show the error messages if something isn&#8217;t filled in right. After every paragraph (&lt;p&gt;content&lt;/p&gt;) we will check if the error variables are not empty and if they aren&#8217;t then echo that error. This is how it looks after all the fields are updated.</p>
<pre class="brush: php;">
&lt;p&gt;&lt;label for=&quot;c_name&quot;&gt;&lt;?php _e('Name') ?&gt;&lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;c_name&quot; id=&quot;c_name&quot; /&gt;&lt;/p&gt;
&lt;?php if($name_error != '') { ?&gt;
	&lt;p class=&quot;error&quot;&gt;&lt;?php echo $name_error;?&gt;&lt;/p&gt;
&lt;?php } ?&gt;

&lt;p&gt;&lt;label for=&quot;c_email&quot;&gt;&lt;?php _e('Email') ?&gt;&lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;c_email&quot; id=&quot;c_email&quot; /&gt;&lt;/p&gt;
&lt;?php if($email_error != '') { ?&gt;
	&lt;p class=&quot;error&quot;&gt;&lt;?php echo $email_error;?&gt;&lt;/p&gt;
&lt;?php } ?&gt;

&lt;p&gt;&lt;label for=&quot;c_subject&quot;&gt;&lt;?php _e('Subject') ?&gt;&lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;c_subject&quot; id=&quot;c_subject&quot; /&gt;&lt;/p&gt;
&lt;?php if($subject_error != '') { ?&gt;
	&lt;p class=&quot;error&quot;&gt;&lt;?php echo $subject_error;?&gt;&lt;/p&gt;
&lt;?php } ?&gt;

&lt;p&gt;&lt;label for=&quot;c_message&quot;&gt;&lt;?php _e('Message') ?&gt;&lt;/label&gt; &lt;textarea name=&quot;c_message&quot; id=&quot;c_message&quot;&gt;&lt;/textarea&gt;&lt;/p&gt;
&lt;?php if($message_error != '') { ?&gt;
	&lt;p class=&quot;error&quot;&gt;&lt;?php echo $message_error;?&gt;&lt;/p&gt;
&lt;?php } ?&gt;

&lt;p&gt;&lt;label for=&quot;c_submit&quot;&gt;&amp;nbsp;&lt;/label&gt; &lt;input type=&quot;submit&quot; name=&quot;c_submit&quot; id=&quot;c_submit&quot; /&gt;&lt;/p&gt;
</pre>
<p>That&#8217;s it. Hope i was clear enough about this part, let me know if you have any questions.</p>
<h2>Step 5 &#8211; Validation and ajax submissions with jQuery </h2>
<p>I made some comments inside the code to explain what&#8217;s what but if you don&#8217;t understand something feel free to ask.</p>
<pre class="brush: jscript;">
&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--//--&gt;&lt;![CDATA[//&gt;&lt;!--

	jQuery(document).ready(function(){

		jQuery('#contact-form form').submit(function(e){

			//prevent the normal processing
			e.preventDefault();

			//delete the errors (so we don't get duplicates ')
			jQuery(&quot;#contact-form .error&quot;).remove();

			//declaring and setting vars
			var value, theID, empty_error, email_error, error, emailReg;
			empty_error = '&lt;p class=&quot;error&quot;&gt;This field is required&lt;/p&gt;';
			email_error = '&lt;p class=&quot;error&quot;&gt;The email you entered is not valid&lt;/p&gt;';
			error = false;
			emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;				

			//validating
			jQuery('#contact-form textarea, #contact-form input[type=text]').each(function(){
				value = jQuery(this).val();
				theID = jQuery(this).attr('id');
				if(value == ''){
					jQuery(this).parent().append('&lt;p class=&quot;error&quot;&gt;'+empty_error+'&lt;/p&gt;');
					error = true;
				}
				if(theID == 'c_email' &amp;&amp; value != '' &amp;&amp; !emailReg.test(value)){
					jQuery(this).parent().append('&lt;p class=&quot;error&quot;&gt;'+email_error+'&lt;/p&gt;');
					error = true;
				}
			});

			//send email and loaded message
			if(error == false){
				jQuery('#contact-form').load('&lt;?php the_permalink(); ?&gt; .email-sent', jQuery('#contact-form form').serialize());
			}

		});

	});

//--&gt;!]]&gt;
&lt;/script&gt;
</pre>
<h2>Step 6 &#8211; Adding the page</h2>
<p>Now when everything is coded let&#8217;s create the page, follow these steps:</p>
<ul>
<li>Go to the create new page in the admin panel</li>
<li>On the right side, bellow the &#8220;publish&#8221; widget you should see &#8220;attributes&#8221; widget, in the template dropdown/selectbox choose &#8220;Contact Form&#8221;</li>
<li>If you want to show some content before the contact form simply add it like when you add content for any other page/post.</li>
<li>Hit publish and that&#8217;s it.</li>
</ul>
<h2>Notice</h2>
<p>Have in mind that if you are building a plugin or theme for wide use then you should read more about <a href='http://codex.wordpress.org/Writing_a_Plugin#Internationalizing_Your_Plugin' target='_blank'>internationalizing plugins and themes</a>.  That way it can be translated easily to more languages.</p>
<h2>Final Words</h2>
<p>We&#8217;re done. If you would also like this contact page to have javascript/jQuery validation and ajax processing then say so in the comments and i&#8217;ll update this tutorial.</p>
<p>Hope it was easy to follow this tutorial and if you liked it then <a href='http://twitter.com/wpcanyon' target='_blank'>follow wpCanyon on twitter</a> or <a href='http://feeds.feedburner.com/wpcanyon' target='_blank'>subscribe to the RSS feed</a>, you don&#8217;t want to miss out on more cool tuts like this one, don&#8217;t you?</p>
]]></content:encoded>
			<wfw:commentRss>http://wpcanyon.com/tutorials/creating-a-contact-page-from-scratch-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Best On WordPress From The Past Week N.8</title>
		<link>http://wpcanyon.com/roundups/best-on-wordpress-from-the-past-week-n-8/</link>
		<comments>http://wpcanyon.com/roundups/best-on-wordpress-from-the-past-week-n-8/#comments</comments>
		<pubDate>Mon, 31 May 2010 09:32:52 +0000</pubDate>
		<dc:creator>Boba</dc:creator>
				<category><![CDATA[Roundups]]></category>

		<guid isPermaLink="false">http://wpcanyon.com/?p=623</guid>
		<description><![CDATA[This is our weekly roundup of the best wordpress articles, tips, tricks and news from the past week we ware able to find on the web.]]></description>
			<content:encoded><![CDATA[<p>All of these were tweeted on our twitter account during the past week, so don&#8217;t forget to <a href='http://wpcanyon.com' target='_blank'>follow wpCanyon on twitter</a> for awesome wordpress related links.</p>
<h2><a href='http://wpshout.com/featured-content-wordpress/' target='_blank'>Build A WordPress Powered Featured Content Area</a></h2>
<p><a href='http://wpshout.com/featured-content-wordpress/' target='_blank'><img src='http://wpcanyon.com/post-images/topweek8/top1.png' alt='Build A WordPress Powered Featured Content Area' /></a></p>
<h2><a href='http://digwp.com/2010/05/default-wordpress-css-styles-hooks/' target='_blank'>WordPress Default CSS Styles</a></h2>
<p><a href='http://digwp.com/2010/05/default-wordpress-css-styles-hooks/' target='_blank'><img src='http://wpcanyon.com/post-images/topweek8/top2.png' alt='WordPress Default CSS Styles' /></a></p>
<h2><a href='http://www.deluxeblogtips.com/2010/05/search-by-category-wordpress.html' target='_blank'>How To Create Search By Category Functionality In WordPress</a></h2>
<p><a href='http://www.deluxeblogtips.com/2010/05/search-by-category-wordpress.html' target='_blank'><img src='http://wpcanyon.com/post-images/topweek8/top3.png' alt='How To Create Search By Category Functionality In WordPress' /></a></p>
<h2><a href='http://blogfreakz.com/wordpress-themes/free-psd-wordpress-theme/' target='_blank'>15 High Quality Free PSD WordPress Theme</a></h2>
<p><a href='http://blogfreakz.com/wordpress-themes/free-psd-wordpress-theme/' target='_blank'><img src='http://wpcanyon.com/post-images/topweek8/top4.png' alt='15 High Quality Free PSD WordPress Theme' /></a></p>
<h2><a href='http://www.onextrapixel.com/2010/05/27/aqualine-a-free-minimalist-wordpress-theme/' target='_blank'>Aqualine: A Free Minimalist WordPress Theme</a></h2>
<p><a href='http://www.onextrapixel.com/2010/05/27/aqualine-a-free-minimalist-wordpress-theme/' target='_blank'><img src='http://wpcanyon.com/post-images/topweek8/top5.png' alt='Aqualine: A Free Minimalist WordPress Theme' /></a></p>
<h2><a href='http://themethesis.com/tutorials/featured-slider-thesis/' target='_blank'>Adding A Featured Content Slider To Thesis In 5 Quick Steps</a></h2>
<p><a href='http://themethesis.com/tutorials/featured-slider-thesis/' target='_blank'><img src='http://wpcanyon.com/post-images/topweek8/top6.png' alt='Adding A Featured Content Slider To Thesis In 5 Quick Steps' /></a></p>
<h2><a href='http://www.famousbloggers.net/top-niche-web-designers-thesis-theme.html?utm_source=twitterfeed&#038;utm_medium=twitter' target='_blank'>What Top Niche Web Designers Say about Thesis Theme for WordPress</a></h2>
<p><a href='http://www.famousbloggers.net/top-niche-web-designers-thesis-theme.html?utm_source=twitterfeed&#038;utm_medium=twitter' target='_blank'><img src='http://wpcanyon.com/post-images/topweek8/top7.png' alt='What Top Niche Web Designers Say about Thesis Theme for WordPress' /></a></p>
<h2><a href='http://wordpress.org/development/2010/05/wordpress-3-0-release-candidate/' target='_blank'>WordPress 3.0 Release Candidate</a></h2>
<p><a href='http://wordpress.org/development/2010/05/wordpress-3-0-release-candidate/' target='_blank'><img src='http://wpcanyon.com/post-images/topweek8/top8.png' alt='WordPress 3.0 Release Candidate' /></a></p>
<h2><a href='http://net.tutsplus.com/tutorials/wordpress/rock-solid-wordpress-3-0-themes-using-custom-post-types/' target='_blank'>Rock-Solid WordPress 3.0 Themes using Custom Post Types</a></h2>
<p><a href='http://net.tutsplus.com/tutorials/wordpress/rock-solid-wordpress-3-0-themes-using-custom-post-types/' target='_blank'><img src='http://wpcanyon.com/post-images/topweek8/top9.png' alt='Rock-Solid WordPress 3.0 Themes using Custom Post Types' /></a></p>
<h2><a href='http://www.binarymoon.co.uk/2010/05/wordpress-caching-part-2/' target='_blank'>WordPress caching, Part 2</a></h2>
<p><a href='http://www.binarymoon.co.uk/2010/05/wordpress-caching-part-2/' target='_blank'><img src='http://wpcanyon.com/post-images/topweek8/top10.png' alt='WordPress caching, Part 2' /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://wpcanyon.com/roundups/best-on-wordpress-from-the-past-week-n-8/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced) (user agent is rejected)

Served from: wpcanyon.com @ 2010-09-08 22:29:00 -->