<?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>Earthman Web &#38; Media &#187; Wordpress</title>
	<atom:link href="http://web.earthman.ca/category/wordpress/feed" rel="self" type="application/rss+xml" />
	<link>http://web.earthman.ca</link>
	<description>Web Design in BC - Nelson, Vancouver, Kelowna</description>
	<lastBuildDate>Sun, 05 Feb 2012 20:30:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>WordPress Plugin Development Essentials: New Premium Course</title>
		<link>http://feedproxy.google.com/~r/nettuts/~3/EtbrDcX9TJE/</link>
		<comments>http://feedproxy.google.com/~r/nettuts/~3/EtbrDcX9TJE/#comments</comments>
		<pubDate>Tue, 06 Dec 2011 19:24:11 +0000</pubDate>
		<dc:creator>Jeffrey Way</dc:creator>
				<category><![CDATA[plugin development]]></category>
		<category><![CDATA[Premium]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://net.tutsplus.com/?p=23135</guid>
		<description><![CDATA[So you’ve wrapped your mind around the process of creating WordPress themes, and now you want to take things to the next level? In that case, it’s time to begin learning how to create plugins for WordPress. In this Tuts+ Premium course, we start fr...]]></description>
			<content:encoded><![CDATA[<a href='http://rss.buysellads.com/click.php?z=1260013&k=d754f1e9ba63a736ba8ff5ece958f7dd&a=23135&c=84018273' ><img src='http://rss.buysellads.com/img.php?z=1260013&k=d754f1e9ba63a736ba8ff5ece958f7dd&a=23135&c=84018273' border='0' alt='' /></a><p>So you’ve wrapped your mind around the process of creating WordPress themes, and now you want to take things to the next level? In that case, it’s time to begin learning how to create plugins for WordPress. In this <a href="http://tutsplus.com/course/wordpress-plugin-development-essentials/">Tuts+ Premium course</a>, we start from the absolute basics, and work our way up to more advanced topics and techniques.</p>
<p><span id="more-23135"></span></p>
<p>With hours of training, and nearly fifty videos, I&#8217;ll teach you, step by step, how to work with shortcodes, widgets, custom post types, WP Cron, and much more. If you&#8217;re unfamiliar with Tuts+ Premium, for $19 a month, you gain access to hundreds upon hundreds of tutorials, an entire catalog of ebooks from <a href="http://feedproxy.google.com/~r/nettuts/~3/EtbrDcX9TJE/rockable.com">Rockable Press</a> and Smashing Magazine, and our new courses section (to be updated a few times every month). </p>
<blockquote><p>If you&#8217;re on the fence, try <a href="http://tutsplus.com/take-the-tour/?WT.z_tour=head">signing up</a> for a single month, and see how it goes! We have a 30-day, no questions asked, money back promise. </p>
</blockquote>
<div class="tutorial_image">
   <a href="http://tutsplus.com/course/wordpress-plugin-development-essentials/"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/1101_wpPlugins/snap.jpg" alt="Tuts Plus" /></a>
</div>
<hr />
<h2>Questions? </h2>
<p>If you have any questions about the <a href="http://tutsplus.com">Tuts+ Premium</a> service, just leave a comment; I&#8217;d be glad to help out any way that I can.</p>
<p><a href="http://feedads.g.doubleclick.net/~a/lISUBZjP1oEEdzYXd3fTW5HfeCg/0/da"><img src="http://feedads.g.doubleclick.net/~a/lISUBZjP1oEEdzYXd3fTW5HfeCg/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/lISUBZjP1oEEdzYXd3fTW5HfeCg/1/da"><img src="http://feedads.g.doubleclick.net/~a/lISUBZjP1oEEdzYXd3fTW5HfeCg/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/nettuts?a=EtbrDcX9TJE:kl5Vdc4s3oY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/nettuts?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/nettuts?a=EtbrDcX9TJE:kl5Vdc4s3oY:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/nettuts?i=EtbrDcX9TJE:kl5Vdc4s3oY:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/nettuts?a=EtbrDcX9TJE:kl5Vdc4s3oY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/nettuts?i=EtbrDcX9TJE:kl5Vdc4s3oY:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/nettuts?a=EtbrDcX9TJE:kl5Vdc4s3oY:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/nettuts?i=EtbrDcX9TJE:kl5Vdc4s3oY:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/nettuts?a=EtbrDcX9TJE:kl5Vdc4s3oY:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/nettuts?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/nettuts/~4/EtbrDcX9TJE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://net.tutsplus.com/tutorials/wordpress/wordpress-plugin-development-essentials/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Magic of WordPress Custom Post Types: New on Premium</title>
		<link>http://feedproxy.google.com/~r/nettuts/~3/Ltq6b_J9JeE/</link>
		<comments>http://feedproxy.google.com/~r/nettuts/~3/Ltq6b_J9JeE/#comments</comments>
		<pubDate>Wed, 19 Oct 2011 19:14:02 +0000</pubDate>
		<dc:creator>Jeffrey Way</dc:creator>
				<category><![CDATA[custom post types]]></category>
		<category><![CDATA[meta boxes]]></category>
		<category><![CDATA[Premium]]></category>
		<category><![CDATA[taxonomies]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://net.tutsplus.com/?p=22330</guid>
		<description><![CDATA[In this in depth Premium video tutorial, I&#8217;ll teach you how to use custom post types, taxonomies, and meta boxes to extend your WordPress application into CMS-like territory. 
Become a Premium member to read this tutorial/screencast, as well as h...]]></description>
			<content:encoded><![CDATA[<a href='http://rss.buysellads.com/click.php?z=1260013&k=d754f1e9ba63a736ba8ff5ece958f7dd&a=22330&c=1962130183' ><img src='http://rss.buysellads.com/img.php?z=1260013&k=d754f1e9ba63a736ba8ff5ece958f7dd&a=22330&c=1962130183' border='0' alt='' /></a><p>In this in depth Premium video tutorial, I&#8217;ll teach you how to use custom post types, taxonomies, and meta boxes to extend your WordPress application into CMS-like territory. </p>
<p><a href="http://net.tutsplus.com/about/join-plus/" >Become a Premium member</a> to read this tutorial/screencast, as well as hundreds of other advanced tutorials and screencasts from the Tuts+ network.</p>
<p><span id="more-22330"></span></p>
<hr />
<h2>You&#8217;ll Learn About&#8230; </h2>
<ul>
<li>What are custom post types, and why would you want to use them?</li>
<li>How to take advantage of custom taxonomies to provide additional grouping and filtering functionality</li>
<li>How to use custom meta boxes to save and display custom meta information for a specific post type.</li>
<li>Implement nonces to provide additional security.</li>
<li>New PHP 5.3 features, such as anonymous functions and closures.</li>
<li>Plenty more&hellip;</li>
</ul>
<p><a href="http://net.tutsplus.com/about/join-plus/" >Become a Premium member</a> to read this tutorial/screencast, as well as hundreds of other advanced tutorials and screencasts from the Tuts+ network. For more WordPress tutorials every day, be sure to subscribe to our sister-site, <a href="http://wp.tutsplus.com">WPtuts+</a>!</p>
<p><a href="http://feedads.g.doubleclick.net/~a/nU8F8SC0yfRUr9GJ50jOHF125Tc/0/da"><img src="http://feedads.g.doubleclick.net/~a/nU8F8SC0yfRUr9GJ50jOHF125Tc/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/nU8F8SC0yfRUr9GJ50jOHF125Tc/1/da"><img src="http://feedads.g.doubleclick.net/~a/nU8F8SC0yfRUr9GJ50jOHF125Tc/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/nettuts?a=Ltq6b_J9JeE:839McZRc4ME:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/nettuts?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/nettuts?a=Ltq6b_J9JeE:839McZRc4ME:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/nettuts?i=Ltq6b_J9JeE:839McZRc4ME:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/nettuts?a=Ltq6b_J9JeE:839McZRc4ME:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/nettuts?i=Ltq6b_J9JeE:839McZRc4ME:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/nettuts?a=Ltq6b_J9JeE:839McZRc4ME:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/nettuts?i=Ltq6b_J9JeE:839McZRc4ME:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/nettuts?a=Ltq6b_J9JeE:839McZRc4ME:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/nettuts?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/nettuts/~4/Ltq6b_J9JeE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://net.tutsplus.com/tutorials/wordpress/the-magic-of-wordpress-custom-post-types-new-on-premium/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create a Multi-Layout Portfolio with WordPress</title>
		<link>http://net.tutsplus.com/tutorials/wordpress/create-a-multi-layout-portfolio-with-wordpress/</link>
		<comments>http://net.tutsplus.com/tutorials/wordpress/create-a-multi-layout-portfolio-with-wordpress/#comments</comments>
		<pubDate>Tue, 31 May 2011 18:11:50 +0000</pubDate>
		<dc:creator>Sumeet Chawla</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[wordpress theme]]></category>

		<guid isPermaLink="false">http://net.tutsplus.com/?p=20304</guid>
		<description><![CDATA[<a href="http://rss.buysellads.com/click.php?z=1260013&#38;k=d754f1e9ba63a736ba8ff5ece958f7dd&#38;a=20304&#38;c=1115591782" target="_blank"><img src="http://rss.buysellads.com/img.php?z=1260013&#38;k=d754f1e9ba63a736ba8ff5ece958f7dd&#38;a=20304&#38;c=1115591782" border="0" alt="" /></a>WordPress, as a content management system, is often used for creating portfolio websites. With the evolution of user interface design and functionalities, a new trend has emerged: displaying portfolio items in different layouts. This tutorial details the process of creating a dedicated portfolio section in WordPress&#8217; backend, and using jQuery and CSS3 to display the [...]]]></description>
			<content:encoded><![CDATA[<a href='http://rss.buysellads.com/click.php?z=1260013&k=d754f1e9ba63a736ba8ff5ece958f7dd&a=20304&c=1672618733' ><img src='http://rss.buysellads.com/img.php?z=1260013&k=d754f1e9ba63a736ba8ff5ece958f7dd&a=20304&c=1672618733' border='0' alt='' /></a><p>WordPress, as a content management system, is often used for creating portfolio websites. With the evolution of user interface design and functionalities, a new trend has emerged: displaying portfolio items in different layouts. This tutorial details the process of creating a dedicated portfolio section in WordPress&#8217; backend, and using jQuery and CSS3 to display the portfolio in a classy manner.
</p>
<p><span id="more-20304"></span></p>
<hr/>
<p>In this tutorial, we are going to extensively use powerful features of WordPress, such as custom posts, custom taxonomies, and we&#8217;ll also write a function to fetch our own custom excerpts.</p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/988_wp-multilayout/final-preview.jpg" border="0" /></div>
<hr />
<h2> <span>Step 1 -</span> Installing WordPress and Initializing the Theme.</h2>
<p>The first step in creating our portfolio website is to install <a href="http://wordpress.org/"  >WordPress</a>.  This is a simple task, and, even better, most web hosts out there provide one click installers. However, if you are new to this, here is an <a href="http://codex.wordpress.org/Installing_WordPress" >awesome guide </a> to help you out with the installation.
</p>
<p>
Once the installation has completed, we should next create our custom theme which will display our portfolio. There are various methods for creating custom themes. Some prefer to create a new blank white template, while others choose to create <a href="http://codex.wordpress.org/Child_Themes" >child themes</a> of the new TwentyTen template. For this tutorial, we will use the <a href="http://starkerstheme.com/" >Starker&apos;s theme</a>, by Elliot Jay Stocks. It&apos;s a completely blank theme with no styling; it&#8217;s a great base to build our theme on. Edit the <code>styles.css</code> file, and change the theme name referenced at the top. To install the theme, simply paste the theme folder in the<code>wp-content &gt; themes</code> folder. Once the theme is installed, you can activate it by going to the <code>themes</code> page.
</p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/988_wp-multilayout/change-theme.jpg" border="0" /></div>
<hr />
<h2> <span>Step 2 -</span> Planning the Layout</h2>
<p>Our portfolio site will not contain much data. A basic portfolio site contains images of the projects, some tags to identify the projects, and a short description of each. The multi-layout theme will function in such a way that the user can select between a grid and list layout. Like many multi layout websites available, we are not going to load a different page when the user clicks on the list view or the grid view. Instead, we&#8217;ll use AJAX to asynchronously load in the new viewer. This is the basic design of how our portfolio site will appear in grid mode:
</p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/988_wp-multilayout/grid-layout-view.jpg" border="0" /></div>
<p>Once the user clicks on the list view control, the whole layout will smoothly change to a list view which will contain the title of the project, the tags associated with it, and a short description.
</p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/988_wp-multilayout/list-layout-view.jpg" border="0" /></div>
<hr />
<h2> <span>Step 3 -</span> Setting up the Backend</h2>
<p>For our portfolio, we need to register a custom post type, called &#8220;project.&#8221; We can customize every aspect of a WordPress post. For example, we can change the labels involved, select various features for the post like comments, thumbnails, excerpts, etc.
</p>
<p>
To implement a custom post, edit the <code>functions.php</code> file located within the <code>theme</code> folder. It contains a lot of predefined code, as the naked Starkers theme provides some functionalities of the default TwentyTen template. Don&#8217;t be scared or confused; you can append the following code either at the bottom or top of the <code>functions.php</code> file.
</p>
<blockquote class="pullquote pqRight">
<p>
Don&#8217;t leave any empty space at the end of the <code>functions.php</code> file.
</p>
</blockquote>
<p> We hook our custom function to the initialization (<code>init</code>) action in the following way:</p>
<pre name="code" class="php">
/*--- Creating custom post type for project --*/
add_action('init', 'project_custom_init');
</pre>
<p>
This <code>project_custom_init</code> method will be used to register the custom post type in the WordPress database.  </p>
<blockquote>
<p>You can learn in detail about the method involved in registering a custom post type <a href="http://codex.wordpress.org/Function_Reference/register_post_type" >here</a>.
</p>
</blockquote>
<p>The <code>register_post_type</code> method requires a name for the custom post, and a set of arguments, which define the characteristics of the custom post. Firstly, we need to define the labels for the custom post. These labels will be used for the custom post in the WordPress admin.
</p>
<pre name="code" class="php">
/*-- Custom Post Init Begin --*/
function project_custom_init()
{
  $labels = array(
    'name' => _x('Projects', 'post type general name'),
    'singular_name' => _x('Project', 'post type singular name'),
    'add_new' => _x('Add New', 'project'),
    'add_new_item' => __('Add New Project'),
    'edit_item' => __('Edit Project'),
    'new_item' => __('New Project'),
    'view_item' => __('View Project'),
    'search_items' => __('Search Projects'),
    'not_found' =>  __('No projects found'),
    'not_found_in_trash' => __('No projects found in Trash'),
    'parent_item_colon' => '',
    'menu_name' => 'Project'

  );
</pre>
<p>Once we&#8217;ve defined the labels, we need to define the set of arguments for the custom post type. The labels array defined earlier is going to be an argument as well. Once the arguments are defined, we register the custom post type as &#8220;project&#8221;.
</p>
<pre name="code" class="php">
 $args = array(
    'labels' => $labels,
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true,
    'show_in_menu' => true,
    'query_var' => true,
    'rewrite' => true,
    'capability_type' => 'post',
    'has_archive' => true,
    'hierarchical' => false,
    'menu_position' => null,
    'supports' => array('title','editor','author','thumbnail','excerpt','comments')
  );
  // The following is the main step where we register the post.
  register_post_type('project',$args);
}
/*-- Custom Post Init Ends --*/
</pre>
<h3> Create Custom Messages for the &apos;Project&apos; Post</h3>
<p>We can also optionally add custom messages for the custom post type. These messages will be displayed in the WordPress dashboard when we edit or update the custom post. We can do this by creating a filter for the post updated messages in the following manner:
</p>
<pre name="code" class="php">
// Add filter to ensure the text Project, or project, is displayed when a user updates a book
add_filter('post_updated_messages', 'project_updated_messages');
function project_updated_messages( $messages ) {
  global $post, $post_ID;

  $messages['project'] = array(
    0 => '', // Unused. Messages start at index 1.
    1 => sprintf( __('Project updated. <a href="http://net.tutsplus.com/tutorials/wordpress/create-a-multi-layout-portfolio-with-wordpress/%25s">View project</a>'), esc_url( get_permalink($post_ID) ) ),
    2 => __('Custom field updated.'),
    3 => __('Custom field deleted.'),
    4 => __('Project updated.'),
    /* translators: %s: date and time of the revision */
    5 => isset($_GET['revision']) ? sprintf( __('Project restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
    6 => sprintf( __('Project published. <a href="http://net.tutsplus.com/tutorials/wordpress/create-a-multi-layout-portfolio-with-wordpress/%25s">View project</a>'), esc_url( get_permalink($post_ID) ) ),
    7 => __('Project saved.'),
    8 => sprintf( __('Project submitted. <a  href="http://net.tutsplus.com/tutorials/wordpress/create-a-multi-layout-portfolio-with-wordpress/%25s">Preview project</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
    9 => sprintf( __('Project scheduled for: <strong>%1$s</strong>. <a  href="http://net.tutsplus.com/tutorials/wordpress/create-a-multi-layout-portfolio-with-wordpress/%252$s">Preview project</a>'),
      // translators: Publish box date format, see http://php.net/date
      date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ),
    10 => sprintf( __('Project draft updated. <a  href="http://net.tutsplus.com/tutorials/wordpress/create-a-multi-layout-portfolio-with-wordpress/%25s">Preview project</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
  );

  return $messages;
}
</pre>
<h3>Registering a Custom Taxonomy</h3>
<p>
We next need to define a custom taxonomy for the tags to be used with each of the portfolio items. You can learn more about the register taxonomy method <a href="http://codex.wordpress.org/Function_Reference/register_taxonomy" >here</a>.
</p>
<pre name="code" class="php">
// Initialize New Taxonomy Labels
  $labels = array(
    'name' => _x( 'Tags', 'taxonomy general name' ),
    'singular_name' => _x( 'Tag', 'taxonomy singular name' ),
    'search_items' =>  __( 'Search Types' ),
    'all_items' => __( 'All Tags' ),
    'parent_item' => __( 'Parent Tag' ),
    'parent_item_colon' => __( 'Parent Tag:' ),
    'edit_item' => __( 'Edit Tags' ),
    'update_item' => __( 'Update Tag' ),
    'add_new_item' => __( 'Add New Tag' ),
    'new_item_name' => __( 'New Tag Name' ),
  );
// Custom taxonomy for Project Tags
register_taxonomy('tag',array('project'), array(
    'hierarchical' => false,
    'labels' => $labels,
    'show_ui' => true,
    'query_var' => true,
    'rewrite' => array( 'slug' => 'tag' ),
  ));
</pre>
<p>Return to your WordPress dashboard, and open the media settings from the <code>settings</code> tab. Here, you have to set the default size for the portfolio image thumbnails. You&#8217;ll also notice in the sidebar that the &#8220;Project&#8221; custom post type has been successfully registered, along with the custom taxonomy, &#8220;tags.&#8221; We can register the default thumbnail size using the <code>set_post_thumbnail</code> method, but I&#8217;ll demonstrate another way to achieve this. You can learn more about how to set post thumbnail sizes programmatically <a href="http://codex.wordpress.org/Function_Reference/set_post_thumbnail_size" >here</a>.
</p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/988_wp-multilayout/default-thumbnail-size.jpg" border="0" /></div>
<h3> Create Demo Portfolio Items </h3>
<p>Create some demo portfolio items by going to <code>projects</code> and clicking on <code>add new</code>. We require a title for the project, the content, and a thumbnail. We can see that a tag section has also appeared and confirms that our custom taxonomy was successfully registered. Add some tags for the portfolio items, as well.
</p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/988_wp-multilayout/insert-data.jpg" border="0" /></div>
<hr />
<h2> <span>Step 4</span> Coding and Styling The Template </h2>
<h3> Coding the static template </h3>
<p>To create the theme, we will first create a static HTML/CSS3 template for the website. This separates the two tasks of making the website look consistent with the design, and fetching the content from the database. Coding the theme directly may be a bit confusing for beginners sometimes &#8211; specially, if a lot of content is present in the theme. Create three folders, named<br />
&#8220;css&#8221;, &#8220;images&#8221; and &#8220;js,&#8221; respectively. The general structure for the main content area will be like so:
</p>
<pre name="code" class="html">
&lt;body>
	&lt;div id="page-wrap">
		&lt;div id="header">
			&lt;!-- Header Content Comes Here -->
		&lt;/div>
		&lt;div id="main-content">
			&lt;div id="layout-controls">
				&lt;!-- Layout Controls Area -->
				&lt;a href="#" class="grid">&lt;span>Grid&lt;/span>&lt;/a>
				&lt;a href="#" class="list">&lt;span>List&lt;/span>&lt;/a>
				&lt;div class="clear">&lt;/div>
			&lt;/div>
			&lt;ul id="folio" class="grid">
				&lt;li> &lt;!-- Portfolio Item -->
					&lt;div class="image">
						&lt;!-- Project Thumbnail Area -->
						&lt;span>
							&lt;a href="#">&lt;img src="" alt=""/>&lt;/a>
						&lt;/span>
						&lt;a href="#" class="link">View Details&lt;/a>
					&lt;/div>
					&lt;div class="content">
						&lt;!-- Project Content Area -->
						&lt;h2>&lt;a href="#">Project Title&lt;/a>&lt;/h2>
						&lt;span class="tags">Tags, Tags&lt;/span>
						&lt;p> The Project Description / Excerpt&lt;/p>
					&lt;/div>
					&lt;div class="clear">&lt;/div>
				&lt;/li>
			&lt;/ul>
			&lt;div class="clear">&lt;/div>
		&lt;/div>&lt;!-- End of Main Content -->
		&lt;div id="footer">
			&lt;!-- Footer Content Comes Here -->
		&lt;/div>
	&lt;/div>&lt;!-- End of Page Wrap -->
&lt;/body>
</pre>
<h3> Style the Template</h3>
<p>Styling the template is dependent on you. You can experiment with different colors and images to suit your needs. But for this template, we are going to create a dark grunge theme and use some fun CSS3 to achieve those subtle hover effects and transparency. The slicing up of the design into images is rather. As such, I won&#8217;t go over the details here.
</p>
<pre name="code" class="css">
body{
	background: #5a5a5a url('images/bg.jpg') no-repeat center top;
	height: 100%;
}
a{
	text-decoration: none;
	color: #C2FC48;
}
a:hover{
	color:#fff;
}
.clear{
	clear: both;
}
#page-wrap{
	width: 960px;
	position: relative;
	margin: 0 auto 40px;
}
#header{
	height: 111px;
	padding: 0 10px 0 50px;
}
#header h1{
	float:left;
}
#header h1 a{
    font-family: Georgia,Arial,Helvetica,sans-serif;
    font-size: 48px;
    position: relative;
    text-decoration: none;
    text-shadow: 2px 2px 1px #000000;
    top: 64px;
    width: auto;
    z-index: 1000;
	-moz-transition: all 0.3s ease-in-out;
	-webkit-transition: all 0.3s ease-in-out;
	-o-transition: all 0.3s ease-in-out;
	transition: all 0.3s ease-in-out;
}
#header h1 a:hover{
	color:#f4f6f0;
}
ul#social{
	float: right;
	top: 95px;
	position:relative;
}
ul#social li{
	float: left;
	margin-right: 10px;
	display: inline;
}
ul#social li a{
	width: 16px;
	height: 16px;
	display: block;
	background-image: url('images/layout-icons.png');
	text-indent: -99999px;
}
ul#social li a.feed{
	background-position: -16px 32px;
}
ul#social li a.facebook{
	background-position: 0 32px;
}
ul#social li a.twitter{
	background-position: 0 16px;
}
</pre>
<p> The basic styling for the main container and the layout controls are as follows</p>
<pre name="code" class="css">
/*--Main Content Styles Start here --*/
#main-content{
	padding: 50px 50px 28px 50px;
	background-color: #000;
	border-bottom: 1px #696969 solid;
	border-left: 1px #696969 solid;
	border-right: 1px #696969 solid;
	/* Fallback for web browsers that doesn't support RGBa */
	background: rgb(0, 0, 0);
	/* RGBa with 0.3 opacity */
	background: rgba(0, 0, 0, 0.3);
	font-family: Helvetica, Arial, sans-serif;
	font-size: 12px;
	color:#c7c7c7;
	line-height: 16px;
}
#main-content a:hover{
	color: #fff;
}
#layout-controls{
	margin-bottom: 15px;
}
#layout-controls span{
	width: 20px;
	height: 26px;
	display: block;
	background-image: url('images/layout-icons.png');
	-moz-transition: all 0.3s ease-in-out;
	-webkit-transition: all 0.3s ease-in-out;
	-o-transition: all 0.3s ease-in-out;
	transition: all 0.3s ease-in-out;
	text-indent: -99999px;
}
#layout-controls a{
	width: 20px;
	height: 26px;
	display: block;
	float: left;
	background-image: url('images/layout-icons.png');
	margin-right: 10px;
	display: inline;
}
#layout-controls a.grid span{
	background-position: left 0;
}
#layout-controls a.grid{
	background-position: left -26px;
}
#layout-controls a.list span{
	background-position: right 0;
}
#layout-controls a.list{
	background-position: right -26px;
}
#layout-controls a:hover span{
	opacity: 0; /* other browsers */
	filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0); /* this works in IE6, IE7, and IE8 */
}
</pre>
<p>The following are the general styles for the project list. We will later do specific styling for each grid layout mode and a list layout mode depending on the current class of the folio list.</p>
<pre name="code" class="css">
/*-------------General Folio Styles Starts Here---------------*/
ul#folio li a{
	-moz-transition: all 0.3s ease-in-out;
	-webkit-transition: all 0.3s ease-in-out;
	-o-transition: all 0.3s ease-in-out;
	transition: all 0.3s ease-in-out;
}
ul#folio li{
	/* Fallback for web browsers that doesn't support RGBa */
	background: rgb(0, 0, 0);
	/* RGBa with 0.3 opacity */
	background: rgba(0, 0, 0, 0.3);
	padding: 20px;
	border: 1px #4c4c4c solid;
	margin-bottom: 22px;
	-moz-transition: all 0.3s ease-in-out;
	-webkit-transition: all 0.3s ease-in-out;
	-o-transition: all 0.3s ease-in-out;
	transition: all 0.3s ease-in-out;
}
ul#folio li:hover{
	/* Fallback for web browsers that doesn't support RGBa */
	background: rgb(0, 0, 0);
	/* RGBa with 0.3 opacity */
	background: rgba(0, 0, 0, 0.1);
}
ul#folio li .image{
	text-align: center;
}
ul#folio li .image span{
	width: 158px;
	height: 116px;
	display: block;
	overflow: hidden;
	background-color: #fff;
	margin-bottom: 10px;
}
ul#folio li .image span a{
	width: 158px;
	height: 116px;
	display: block;
}
ul#folio li .image a{
	font-weight: bold;
}
</pre>
<p>Also make note that we are not using the general opacity method of achieving transparency using CSS3. Using the opacity method also affects the children of the parent container on which the opacity is applied. Instead, we are using the RGBa method of adding background colors to the container, and using the alpha value to control the transparency of the container. </p>
<blockquote>
<p>You can read more about the RGBa Property in this awesome <a href="http://css-tricks.com/rgba-browser-support/" >article</a>. </p>
</blockquote>
<p>This does not affect the transparency of the children elements. We also need to create IE specific CSS code to support the alpha transparency.
</p>
<pre name="code" class="html">
&lt;!--[if IE]>
&lt;style>
#main-content, ul#folio li{
	background:transparent;
    filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#30000000,endColorstr=#30000000);
    zoom: 1;
}
ul#folio li:hover{
	background:transparent;
    filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#10000000,endColorstr=#10000000);
    zoom: 1;
}
&lt;/style>
&lt;![endif]-->
</pre>
<p>In the HTML structure, you will notice that there is a class given to the portfolio list.</p>
<pre name="code" class="html">
&lt;ul id="folio" class="grid">
</pre>
<p>Basically, the &#8220;grid&#8221; class is used to display the list in a grid view and the &#8220;list&#8221; class is used to display the list in a list view. In the grid mode, all the extra content is hidden from the user, and in the list mode, all the content is visible to the user. We have two separate sets of styling for each mode. The styles for the grid mode are as follows:
</p>
<pre name="code" class="css">
/*------------------Grid Layout Starts Here-------------------*/
ul#folio.grid li{
	width: 158px;
	height: 130px;
	float: left;
	margin-right: 19px;
	display: inline;
}
ul#folio.grid li .content{
	display: none;
}
ul#folio.grid li .image span a{
	width: 158px;
	height: 116px;
	display: block;
}
ul#folio.grid li.rightmost{
	margin-right: 0;
}
</pre>
<p>List mode styles are as follows. At any moment, only one of the grid or list styles is active.
</p>
<pre name="code" class="css">
/*------------------List Layout Starts Here-------------------*/
ul#folio.list li{
	display: block;
}
ul#folio.list li .image,ul#folio li.details .image{
	width: 158px;
	height: 130px;
	float:left;
}
ul#folio.list li .content{
	float: left;
	padding: 0 10px 0 40px;
	width: 598px;
}
ul#folio.list li .content h2,ul#folio li.details .content h2{
	font-size: 24px;
	color: #C2FC48;
	margin-bottom: 6px;
	font-family: Georgia, Arial, Helvetica, sans-serif;
}
ul#folio.list li .content span.tags,ul#folio li.details .content span.tags{
	color: #fff;
	font-size: 11px;
	font-style: italic;
	margin-bottom: 10px;
	display: block;
}
</pre>
<h3> Use jQuery to Add Effects</h3>
<p>We next will use <a href="http://www.jqueryui.com">jQuery UI</a> to change the class of the folio list with respect to the layout button clicked by the user. We&#8217;re detecting the click event of the layout control buttons, fetching the current class and the new class to be activated, and then using the <code>add</code> and <code>remove</code> class methods to change the classes. We also have a set of parameters which define the speed of the events taking place.
</p>
<pre name="code" class="js">
	var animateSpeed = 500;
	jQuery("#layout-controls a").click(function(){
               var folio = jQuery('#folio'),
		     curClass = folio.attr('class'),
		     newClass = jQuery(this).attr('class');

		folio.fadeOut(animateSpeed,function(){
			folio
                          .removeClass(curClass,animateSpeed);
			  .addClass(newClass,animateSpeed);
		}).fadeIn(animateSpeed);
		return false;
	});
</pre>
<hr />
<h2> <span>Step 5</span> Integration with the WordPress Theme </h2>
<p>Now that we have completed the static version of the site, we can integrate it with the WordPress theme in a matter of minutes. All we need to do is loop through the posts using a <code>wp_query</code> object with a query for the custom post type. Then, we place the content in the respective position in the template.
</p>
<h3>Edit <code>header.php</code></h3>
<p>First, we need to modify the <code>header.php</code> template, and include our custom JavaScript files. In this tutorial, we&#8217;ll include jQuery using the Google&#8217;s CDN version. We will deregister the jQuery provided by WordPress, and register Google&#8217;s CDN version of jQuery. Paste the following snippet in your <code>functions.php</code> file.
</p>
<pre name="code" class="php">
&lt;?php
/*--- Registering jQuery using Google's CDN */
if( !is_admin()){
   wp_deregister_script('jquery');
   wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"));
   wp_enqueue_script('jquery');
}
?>
</pre>
<p>Move the <code>css</code>, <code>js</code> and <code>images</code> folders &#8211; that you created previously for the static template &#8211; to the WordPress theme folder. Insert the jQuery UI custom file, and the main script file in the header. Make sure it is inserted below the <code>wp_head</code> method.
</p>
<pre name="code" class="php">
&lt;script src="&lt;?php bloginfo('template_url');?>/js/jquery-ui-1.8.11.custom.js">&lt;/script>
&lt;script src="&lt;?php bloginfo('template_url');?>/js/script.js">&lt;/script>
</pre>
<h3>Create the Main Template</h3>
<p>Now, you can either create another template in the theme &#8211; for example, <code>page-home.php</code> &#8211; or you can modify the <code>index.php</code> already present in the theme folder. If you choose the former method, then:
</p>
<ul>
<li>Create a page</li>
<li>Set the page&#8217;s template as the template you just created.</li>
<li> Go to the reading settings in the <code>settings</code> tab. </li>
<li>Select the homepage as a static one.</li>
<li>Select the page you just created as the homepage.</li>
</ul>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/988_wp-multilayout/static-page.jpg" border="0" /></div>
<p>The template will first contain the header, which you can call using the <code>get_header()</code> method, then the main content, which you will code within the template itself. Lastly, the footer, which you can be included, via the <code>get_footer()</code> method.</p>
<p>The following code demonstrates how you can create a custom query using the <code>wp_query</code> object.</p>
<pre name="code" class="php">
&lt;?php $loop = new WP_Query(array('post_type' => 'project', 'posts_per_page' => -1));
  $count =0;
?>
</pre>
<p>We are using a variable, <code>count</code> to count the number of items in the list. We need this because we will keep only four items in each row and assign a &#8216;<code>rightmost</code>&#8216; class to every fourth list element. The &#8216;<code>rightmost</code>&#8216; class eliminates any right margin to the list elements. <em>Alternatively, we could, in our CSS file, use the <code>li:nth-child(4n)</code> selector. </em></p>
<p>The following code shows how we can loop through the posts and insert the content, as required.</p>
<pre name="code" class="php">
&lt;?php if($loop) { ?>
	&lt;ul id="folio" class="grid">
		&lt;?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
</pre>
<p>Inside the loop, we insert the content in the normal WordPress way, using the <code>$loop</code> <code>wp_query</code> object, of course. The following code shows how we can fetch the thumbnail of the project post and insert it into the template. Make proper note of how we use the <code>$count</code> variable to insert the &#8216;<code>rightmost</code>&#8216; class on every fourth list element.</p>
<pre name="code" class="php">
		&lt;li class="item-&lt;?php the_ID() ?> &lt;?php if(++$count%4==0) echo 'rightmost'?> ">
				&lt;div class="image">
					&lt;span>
						&lt;a href="&lt;?php the_permalink() ?>">
							&lt;?php
								if(has_post_thumbnail()){
									the_post_thumbnail('thumbnail');
								}
							?>
						&lt;/a>
					&lt;/span>
					&lt;a href="&lt;?php the_permalink() ?>" class="link">View Details&lt;/a>
				&lt;/div>
</pre>
<p>Now comes the content section where we need to insert the title, tags, short description and fetch the excerpt for the post with a custom excerpt method. Inserting the title is rather easy, as are the tags. Remember, we previously created a custom taxonomy by the name of tags.  </p>
<pre name="code" class="php">
				&lt;div class="content">
					&lt;h2>&lt;a href="&lt;?php the_permalink() ?>">&lt;?php the_title() ?>&lt;/a>&lt;/h2>
					&lt;span class="tags">
						&lt;?php
							// Fetching the tag names with respect to the post and displaying them
							$args = array('orderby' => 'name', 'order' => 'ASC', 'fields' => 'names');
							echo implode(wp_get_object_terms( $post->ID, 'tag', $args),', ');
						?>
					&lt;/span>
					&lt;p>
						&lt;?php
							// Using custom excerpt function to fetch the excerpt
							folio_excerpt('folio_excerpt_length','folio_excerpt_more');
						 ?>
					&lt;/p>
				&lt;/div>
				&lt;div class="clear">&lt;/div>
			&lt;/li>
		&lt;?php endwhile; ?>
	&lt;/ul>
&lt;?php } ?>
&lt;?php wp_reset_query(); ?>
</pre>
<p>You will notice that we are not using the general <code>the_excerpt()</code> method, provided by WordPress. Instead, we are defining our own custom method by adding some filters. The general excerpt method returns a greater length of excerpt than we require. Hence, the custom version. We&#8217;re also modifying the &#8216;Continue Reading&#8230;&#8217; text added at the end of the default excerpt, and replacing it with &#8216;Read More&#8217;. The following snippet serves our purpose. This custom excerpt method comes in handy for plenty of situations.</p>
<pre name="code" class="php">
&lt;?php
// Adding Variable Excerpt Length
function folio_excerpt_length($length) {
    return 80;
}
function folio_excerpt_more($more) {
	return ' ... &lt;span class="excerpt_more">&lt;a href="'.get_permalink().'">Read more&lt;/a>&lt;/span>';
}
function folio_excerpt($length_callback='', $more_callback='') {
    global $post;
    if(function_exists($length_callback)){
        add_filter('excerpt_length', $length_callback);
    }
    if(function_exists($more_callback)){
        add_filter('excerpt_more', $more_callback);
    }
    $output = get_the_excerpt();
    $output = apply_filters('wptexturize', $output);
    $output = apply_filters('convert_chars', $output);
    $output = '&lt;p>'.$output.'&lt;/p>';
    echo $output;
}
?>
</pre>
<hr />
<h2> <span>Step 6</span> Conclusion </h2>
<p>The above method of creating a multi-layout portfolio is quite simple, and uses basic CSS and jQuery tricks to achieve the result. Even better, these techniques can be applied to a variety of projects. Other techniques in this tutorial, like custom post types, custom taxonomies and adding filters to the excerpt method, can be used in various other innovative ways, as well!</p>
]]></content:encoded>
			<wfw:commentRss>http://net.tutsplus.com/tutorials/wordpress/create-a-multi-layout-portfolio-with-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create WordPress Plugins with OOP Techniques</title>
		<link>http://net.tutsplus.com/tutorials/wordpress/create-wordpress-plugins-with-oop-techniques/</link>
		<comments>http://net.tutsplus.com/tutorials/wordpress/create-wordpress-plugins-with-oop-techniques/#comments</comments>
		<pubDate>Thu, 19 May 2011 20:06:27 +0000</pubDate>
		<dc:creator>Muhammad Haris</dc:creator>
				<category><![CDATA[OOP]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://net.tutsplus.com/?p=20153</guid>
		<description><![CDATA[<a href="http://rss.buysellads.com/click.php?z=1260013&#38;k=d754f1e9ba63a736ba8ff5ece958f7dd&#38;a=20153&#38;c=579530726" target="_blank"><img src="http://rss.buysellads.com/img.php?z=1260013&#38;k=d754f1e9ba63a736ba8ff5ece958f7dd&#38;a=20153&#38;c=579530726" border="0" alt="" /></a>Object-oriented code, among other things, can help organize and add reusability to your code. In this tutorial, I will teach you the basics of writing a WordPress plugin using object oriented techniques. We&#8217;ll be using Dribbble&#8217;s API as an example for this tutorial. Ready? What We&#8217;re Going to Learn: Benefits of using OOP for WordPress [...]]]></description>
			<content:encoded><![CDATA[<a href='http://rss.buysellads.com/click.php?z=1260013&k=d754f1e9ba63a736ba8ff5ece958f7dd&a=20153&c=1633212025' ><img src='http://rss.buysellads.com/img.php?z=1260013&k=d754f1e9ba63a736ba8ff5ece958f7dd&a=20153&c=1633212025' border='0' alt='' /></a><p>Object-oriented code, among other things, can help organize and add reusability to your code. In this tutorial, I will teach you the basics of writing a WordPress plugin using object oriented techniques. We&#8217;ll be using Dribbble&#8217;s API as an example for this tutorial. Ready?</p>
<p><span id="more-20153"></span></p>
<hr />
<h2>What We&#8217;re Going to Learn:</h2>
<ul>
<li>Benefits of using OOP for WordPress plugins.</li>
<li>How to setup a shortcode.</li>
<li>How to setup a template tag.</li>
<li>How to enable shortcode in WordPress widgets.</li>
<li>Real-world example by using Dribbble&#8217;s API.</li>
</ul>
<hr />
<h2>Why Use OOP?</h2>
<blockquote>
<p>Before moving forward with this tutorial, you should have at least an elementary understanding of writing a WordPress plugin. Jonathan has written an amazing tutorial on <a href='http://net.tutsplus.com/tutorials/wordpress/your-first-wordpress-plugin-simple-optimization/'>&#8220;How to write a WordPress Plugin&#8221;</a>. Give it a read.</p>
</blockquote>
<p>Creating WordPress plugins with object oriented code is quite efficient and tidy, when compared to using procedural code. It&#8217;s easier to manage the code base, and expand it using inheritance techniques, which can be particularly helpful when writing a large plugin.</p>
<hr />
<h2>Dribbble</h2>
<p>To write a WordPress plugin, we first need a sense of direction. We&#8217;re going to write a plugin that will display the latest shots from <a href='http://dribbble.com'>Dribbble</a>, using their REST API. We&#8217;ll then add shortcode support for posts and widgets, and template tag for themes.</p>
<hr />
<h2> <span>Step 1 -</span> Setting up the Plugin Class</h2>
<p>Object oriented code is based on classes and methods (functions). Let&#8217;s create our core class, which will interact with WordPress&#8217; hooks and filters.</p>
<pre name="code" class="php">
class WPDribbble {
	public function __construct()
	{
	}
}

$wpDribbble = new WPDribbble();
</pre>
<p>PHP classes have a constructor function, <code>__construct</code>, which is executed as soon as a new instance of a class is instantiated. All WordPress hooks and filters will be registered under the constructor of our plugin class. Lets push ahead and register a shortcode for our plugin. The <code>add_shortcode()</code> function/hook will go under the constructor function.</p>
<p>The new instance of a class/object is registered using the <code>new</code> keyword. Refer to the last line in the code below.</p>
<pre name="code" class="php">
class WPDribbble {
	public function __construct()
	{
		add_shortcode('Dribbble', array($this, 'shortcode'));
	}

	public function shortcode()
	{
	}
}

$wpDribbble = new WPDribbble();
</pre>
<ul>
<li><strong>add_shortcode</strong> &#8211; The first parameter is the shortcode tag, and the second is the callback function. </li>
</ul>
<blockquote>
<p>Notice how we&#8217;re using an <code>array</code> in the callback function parameter? To register callback functions inside an object, we have to use an <code>array</code>. </p>
</blockquote>
<p>The first item of the array references the object, via <code>$this</code>. The second item in the <code>array</code> is the method name within the class. All hooks and filters have to be referenced like this when inside a class.</p>
<h3> Still Confused? </h3>
<pre name="code" class="php">
# 1. Standard usage
add_shortcode('shortcode_name', 'shortcode_func');

function shortcode_func()
{
 // Contents of this function will execute when the blogger
// uses the [shortcode_name] shortcode.
}

# 2. With PHP 5.3, we can pass an anonymous function.
add_shortcode('shortcode_name', function() {
   // Contents of this function will execute when the blogger
  // uses the [shortcode_name] shortcode.
});

#3. Within a class
class WPDribbble {
	public function __construct()
	{
		add_shortcode('Dribbble', array($this, 'shortcode'));
	}

	public function shortcode()
	{
           // Contents of this function will execute when the blogger
          // uses the [shortcode_name] shortcode.
	}
}
</pre>
<hr />
<h2> <span>Step 2 -</span> Dribbble API Class</h2>
<p>Since we currently do not require any fancy API functions, we&#8217;re going to create a rather simple API wrapper for Dribbble. There is already a library available for Dribbble, but, for the sake of this tutorial, we&#8217;re going to write our own. It&#8217;ll help you understand the concepts behind this tutorial.</p>
<p>We&#8217;re going to write a DribbbleAPI <code>object</code>, and register a <code>method</code> called <code>getPlayerShots()</code> to interact with Dribbble&#8217;s API and return an <code>array</code> of the latest shots.</p>
<p>Let&#8217;s create a new file for this class, called <code>DribbbleAPI.php</code></p>
<pre name="code" class="php">
class DribbbleAPI {
	// url to Dribbble api
	protected $apiUrl = 'http://api.dribbble.com/';

	// Dribbble username or user id
	protected $user;
}
</pre>
<p>Above, we&#8217;re setting up two class variables.</p>
<ul>
<li><strong>$apiUrl</strong> &#8211; The link to the Dribbble API, where the calls will be sent.</li>
<li><strong>$user</strong> &#8211; The username or user id of a Dribbble user. This value will be set from within the constructor (<code>__construct</code>) method.</li>
</ul>
<pre name="code" class="php">
class DribbbleAPI {
	// url to Dribbble api
	protected $apiUrl = 'http://api.dribbble.com/';

	// Dribbble username or user id
	protected $user;

	public function __construct($user)
	{
		$this->user = $user;
	}
}
</pre>
<p>The constructor is passed a <code>$user</code> variable, which is then passed on by the constructor to the class property, called <code>user</code>. </p>
<p>We prefix the property, or variable name with <code>public</code> to specify that the value of this property can be retrieved from outside of the <code>class</code>. If we instead wish to limit access to the property to only this <code>class</code>, and perhaps any <code>class</code>es that inherit from it, we&#8217;d use the <code>protected</code> prefix. This practice is referred to as encapsulation. </p>
<p>We have the base ready for our Dribbble API wrapper. Now, We&#8217;re going to write a new <code>method</code>, called <code>getPlayerShots()</code>. The purpose of this <code>method</code> will be to query the API and convert the result into an <code>array</code> for usage within our plugin.</p>
<pre name="code" class="php">
class DribbbleAPI {
	// url to Dribbble api
	protected $apiUrl = 'http://api.dribbble.com/';

	// Dribbble username or user id
	protected $user;

	public function __construct($user)
	{
		$this->user = $user;
	}

	public function getPlayerShots($perPage = 15)
	{
		$user = $this->user;

		$json = wp_remote_get($this->apiUrl . 'players/' . $user . '/shots?per_page=' . $perPage);

		$array = json_decode($json['body']);

		$shots = $array->shots;

		return $shots;
	}
}
</pre>
<blockquote class="pullquote">
<p>Learn more about <a href="http://codex.wordpress.org/Function_API/wp_remote_get">wp_remote_get</a>.</p>
</blockquote>
<p>The <code>getPlayerShots</code> function retrives the user from the class variable. It uses WordPress&#8217;  <code>wp_remote_get</code> function to query the Dribbble API. The API then responds to our query with a JSON string, which is then parsed into an <code>array</code> and sent back to the function using the <code>return</code> keyword.</p>
<p>This is all that we require from the API at the moment &#8211; simply an <code>array</code> of player shots. If we happen to require more functionality in the future, we can either add more <code>method</code>s to the current <code>class</code>, or create a new <code>class</code> that <a href='http://php.net/manual/en/keyword.extends.php'>extend</a>s this one. Again, this is referred to as inheritance.</p>
<hr />
<h2> <span>Step 3</span> &#8211; Integrating the <code>DribbbleAPI</code> Class</h2>
<p>This is the fun part; the freshly baked <code>DribbbleAPI</code> <code>class</code> will come into use. We&#8217;re going to loop through the shots retrived from the API, and generate an <code>html</code> list of shots, which will be passed on to the shortcode and the template tag. During the loop, the full-sized Dribbble images will be cached and saved in the plugin folder, and the thumbnails will be generated using <a href='http://www.darrenhoyt.com/2008/04/02/timthumb-php-script-released/'>TimThumb.</a></p>
<p>To determine if the full images are already stored locally, the <code>plugin path</code> is required. Also, to generate the thumbnails with <code>timthumb</code>, the <code>plugin url</code> is required. For this purpose, we&#8217;ll create two class variables called <code>pluginPath</code> and <code>pluginURL</code> in our <code>WPDribbble</code> class, and then set their values from within the constructor <code>method</code>.</p>
<h3>Setting PluginPath and PluginUrl</h3>
<pre name="code" class="php">
class WPDribbble {
	protected $pluginPath;
	protected $pluginUrl;

	public function __construct()
	{
		// Set Plugin Path
		$this->pluginPath = dirname(__FILE__);

		// Set Plugin URL
		$this->pluginUrl = WP_PLUGIN_URL . '/wp-Dribbble';

		add_shortcode('Dribbble', array($this, 'shortcode'));
	}
</pre>
<h3><code>getImages()</code> Method</h3>
<p>Create a new <code>method</code> within the <code>WPDribbble</code> <code>class</code>, called <strong>getImages</strong>.</p>
<blockquote>
<p>Inside a <code>class</code>, you can use generic names for functions. They will not conflict with other plugins or WordPress&#8217; built-in functions, because they are under the <code>class</code> namespace.</p>
</blockquote>
<pre name="code" class="php">
public function getImages($user, $images = 3, $width = 50, $height = 50, $caption = true)
{
}
</pre>
<ul>
<li><strong>$user</strong> &#8211; Username or User ID of Dribbble. <code>$user</code> will be used when registering a new instance of the <code>DribbbleAPI</code> class.</li>
<li><strong>$images</strong> &#8211; Number of images to render. <code>$images</code> will be used when querying the API through the <code>getPlayerShots</code> method.</li>
<li><strong>$width and $height</strong> &#8211; Timthumb will be used to generate thumbnails.</li>
<li><strong>$caption</strong> &#8211; Option to render title of an image.</li>
</ul>
<p>Next, we&#8217;re going to include the <code>DribbbleAPI</code> class in the <code>getImages()</code> function,  and create a new instance of it to grab the images.</p>
<pre name="code" class="php">
public function getImages($user, $images = 3, $width = 50, $height = 50, $caption = true)
{
	include 'DribbbleAPI.php';

	$DribbbleAPI = new DribbbleAPI($user);
	$shots = $DribbbleAPI->getPlayerShots($images);

	if($shots) {
	}
}
</pre>
<p>The <code>$shots</code> variable in the code is populated with an <code>array</code> of three recent Dribbbles from the <code>$user</code>.</p>
<p>As mentioned previously, we&#8217;re going to loop through the <code>$shots</code> <code>array</code>, and save the full size images locally for caching purposes. The cached images will be used with TimThumb to serve the thumbnails. For storing full-images and thumbnails generated by TimThumb, create two folders. We&#8217;ll use <code>full-images/</code> for storing the full size images, and <code>cache/</code> for the thumbnails, since that is the default folder name for TimThumb.</p>
<p>The HTML for the list will be generated within the <code>$shots</code> loop.</p>
<pre name="code" class="php">
public function getImages($user, $images = 3, $width = 50, $height = 50, $caption = true)
{
	include 'DribbbleAPI.php';

	$DribbbleAPI = new DribbbleAPI($user);
	$shots = $DribbbleAPI->getPlayerShots($images);

	if($shots) {
		$html[] = '&lt;ul class="wp-Dribbble"&gt;';

		foreach($shots as $shot) {
			$image = $shot->image_url; // url of the image
			$fileName = $shot->id . '.png'; // generating a filename image_id.png

			if (!file_exists($this->pluginPath . '/full-images/' . $fileName)) { // check if the full image exists
				$rawImage = wp_remote_get($image); // get the full image
				$newImagePath = $this->pluginPath  . '/full-images/' . $fileName;
				$fp = fopen($newImagePath, 'x');
				fwrite($fp, $rawImage['body']); // save the full image
				fclose($fp);
			}

			// generate thumbnail url
			$localImage = $this->pluginUrl . '/timthumb.php?src=' . strstr($this->pluginPath, 'wp-content') . '/full-images/' . $fileName . '&#038;w=' . $width . '&#038;h=' . $height . '&#038;q=100';

			if($caption) { // if caption is true
				$captionHTML = '&lt;p class="wp-Dribbble-caption"&gt;' . $shot->title . '&lt;/p&gt;';
			}

			// combine shot url, title and thumbnail to add to the ul list
			$html[] = '&lt;li class="wp-Dribbble-list">&lt;a href="' . $shot->url . '" title="' . $shot->title . '">&lt;img src="' . $localImage . '" alt="' . $shot->title . '" /&gt;&lt;/a&gt;'.$captionHTML.'&lt;/li&gt;';
		}

		$html[] = '&lt;/ul&gt;';

		return implode("\n", $html);
	}
}
</pre>
<h3>Adding Classes</h3>
<p>It&#8217;s always a good idea to add classes to each element of your plugin. This provides the advanced users of your plugin with the freedom to customize it. Avoid using inline CSS for content that is generated through your plugin.</p>
<hr />
<h2> <span>Step 4</span> &#8211; Setting up the Shortcode</h2>
<blockquote><p>Shortcodes, as the name suggests, allows users to easily add complex content into blog posts.</p>
</blockquote>
<p>We already have the <code>add_shortcode</code> hook ready in our plugin class constructor. Now, we&#8217;re going to write the shortcode <code>method</code> inside our <code>class</code>, which will exract the shortcode attributes and return the Dribbble images by using the <code>getImages()</code> method.</p>
<p>We&#8217;ll be calling our shortcode <code>[Dribbble]</code>. As mentioned previously, the name of the shortcode is determined by the first parameter in the <code>add_shortcode</code> function. It will be used with the attributes required for the <code>getImages()</code> method. For example: <code>[Dribbble user=haris images=5 width=100 height=100 caption=true]</code>.
<pre name="code" class="php">
public function shortcode($atts)
{
	// extract the attributes into variables
	extract(shortcode_atts(array(
		'images' => 3,
		'width' => 50,
		'height' => 50,
		'caption' => true,
	), $atts));

	// pass the attributes to getImages function and render the images
	return $this->getImages($atts['user'], $images, $width, $height, $caption);
}
</pre>
<h3>Add Shortcode support for WordPress Widgets</h3>
<p>By default, WordPress widgets don&#8217;t support shortcodes, however, by using the <code>widget_text</code> filter, we can force shortcode support in WordPress widgets.</p>
<p>We can add the filter in our <code>WPDribbble</code> object constructor.</p>
<pre name="code" class="php">
public function __construct()
{
	// Set Plugin Path
	$this->pluginPath = dirname(__FILE__);

	// Set Plugin URL
	$this->pluginUrl = WP_PLUGIN_URL . '/wp-Dribbble';

	add_shortcode('Dribbble', array($this, 'shortcode'));

	// Add shortcode support for widgets
	add_filter('widget_text', 'do_shortcode');
}
</pre>
<hr />
<h2> <span>Step 5</span> Setting up the Template Tag</h2>
<p>The template tag can be used directly in WordPress themes. The basic purpose of the template tag will be to create a new instance of our <code>WPDribbble</code> class, and call the <code>getImages()</code> method. The template tag will be a simple PHP function and it has to be registered outside the plugin <code>class</code>. It needs to have a unique name; otherwise, it will conflict with functions / plugins with similiar name. Since our plugin is called <code>WP-Dribbble</code>, we&#8217;ll call the template tag, <code>wp_Dribbble()</code>.</p>
<pre name="code" class="php">
function wp_Dribbble($user, $images = 3, $width = 50, $height = 50, $caption = true)
{
	$wpDribbble = new WPDribbble;
	echo $wpDribbble->getImages($user, $images, $width, $height, $caption);
}
</pre>
<hr />
<h2>Voila!</h2>
<p>Congratulations! You have successfully written a WordPress plugin with OOP. If you have any questions, let me know, and I&#8217;ll do my best to help you. .</p>
]]></content:encoded>
			<wfw:commentRss>http://net.tutsplus.com/tutorials/wordpress/create-wordpress-plugins-with-oop-techniques/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Deploy your WordPress Blog to the Cloud</title>
		<link>http://net.tutsplus.com/tutorials/wordpress/deploy-your-wordpress-blog-to-the-cloud/</link>
		<comments>http://net.tutsplus.com/tutorials/wordpress/deploy-your-wordpress-blog-to-the-cloud/#comments</comments>
		<pubDate>Mon, 16 May 2011 16:02:45 +0000</pubDate>
		<dc:creator>Jarkko Laine</dc:creator>
				<category><![CDATA[amazon]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://net.tutsplus.com/?p=20066</guid>
		<description><![CDATA[<a href="http://rss.buysellads.com/click.php?z=1260013&#38;k=d754f1e9ba63a736ba8ff5ece958f7dd&#38;a=20066&#38;c=1446422584" target="_blank"><img src="http://rss.buysellads.com/img.php?z=1260013&#38;k=d754f1e9ba63a736ba8ff5ece958f7dd&#38;a=20066&#38;c=1446422584" border="0" alt="" /></a><p><a href="http://buysellads.com/buy/sitedetails/pubkey/d754f1e9ba63a736ba8ff5ece958f7dd/zone/1260013" target="_blank">Advertise here</a></p>For the last decade, hosting a large scale web application has been a daunting task, reserved only for experts. Not anymore; when Amazon opened its server architecture, everything changed. Computer hardware moved to the cloud, and became available to any and all developers. In this tutorial, we will install WordPress in the cloud. Introduction Most [...]]]></description>
			<content:encoded><![CDATA[<a href='http://rss.buysellads.com/click.php?z=1260013&k=d754f1e9ba63a736ba8ff5ece958f7dd&a=20066&c=111402060' ><img src='http://rss.buysellads.com/img.php?z=1260013&k=d754f1e9ba63a736ba8ff5ece958f7dd&a=20066&c=111402060' border='0' alt='' /></a><p><a href='http://buysellads.com/buy/sitedetails/pubkey/d754f1e9ba63a736ba8ff5ece958f7dd/zone/1260013' >Advertise here</a></p><p> For the last decade, hosting a large scale web application has been a daunting task, reserved only for experts. Not anymore; when Amazon opened its server architecture, everything changed. Computer hardware moved to the cloud, and became available to any and all developers. In this tutorial, we will install WordPress in the cloud. </p>
<p> <span id="more-20066"></span></p>
<hr />
<h2>Introduction</h2>
<p> Most blogs and small business web sites are hosted on shared hosting services, where you pay a fixed monthly fee in exchange for a predefined set of features and installed software. Most of the time, it&#8217;s a perfectly valid option, but running your blog in Amazon&#8217;s cloud comes with benefits that make it an option worth considering: </p>
<ul>
<li><strong>Easy to upgrade.</strong> Creating a new server machine in Amazon&#8217;s cloud can be accomplished in a matter of minutes. So by using the service, you are always prepared to handle instant jumps in traffic. If a post jumps to the front page of Digg or Reddit, you can add more servers and balance the load. accordingly.</li>
<li><strong>Cost-efficient power for large scale services.</strong> If your site attracts a lot of users, and eventually outgrows the limits of your regular hosting, Amazon Web Services gives you free hands in designing a server architecture that matches your needs, in a cost-efficient way, without needing to hire a complete network operations team to do the setup for you! This is how many of the most popular Facebook developers have built their servers.</li>
<li><strong>Total control over the setup:</strong> Though this point might not be too important when running WordPress, if you want to get adventurous and build your next project using something more exotic than a combination of PHP and MySQL, you don&#8217;t have to ask your web hosting company. You install the software you wish, just like you would on a server of your own.</li>
</ul>
<p> Whether or not hosting your WordPress site on Amazon is the right choice depends on the traffic your blog receives, as well as how much you value the opportunity to configure your server exactly to your needs.</p>
<blockquote><p> If you&#8217;re still curious, read on and give it a shot. You will be amazed at how quickly you can get a server up and running! </p>
</blockquote>
<hr />
<h2> <span>Step 1 -</span> Create an Amazon Web Services Account</h2>
<p>Before you can start using Amazon&#8217;s cloud for your web hosting needs, you need to create an account with Amazon Web Services (AWS). Point your browser to <a href="http://aws.amazon.com">aws.amazon.com</a> and click on the &#8220;Sign Up Now&#8221; button.</p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/981_wordpressCloud/0.jpg" border="0"></div>
<p>If you&#8217;ve used Amazon.com before, you can use your same e-mail and password to login to AWS. You can also create a new account by choosing &#8220;<em>I am a new user.</em>&#8221; </p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/981_wordpressCloud/1.jpg" border="0"></div>
<p>At this stage, you will need to enter your contact information and credit card number so that Amazon can bill you for any services you use. Creating an account is free, though everything else will cost you money.</p>
<p><a href="http://aws.amazon.com/ec2/pricing/">The pricing model</a> is rather simple &#8212; you pay for every hour your server is running &#8212; but because of the variety of options, calculating the actual price can get quite a bit more complex than that. When running your own site at Amazon, it&#8217;s best to be careful and double check your price calculations before leaving the servers running unattended so you don&#8217;t get any surprises at the end of the month.</p>
<p>Building our WordPress setup shouldn&#8217;t last but an hour, and we will stop everything when we&#8217;re finished, so the price for completing the tutorial will be close to zero.</p>
<hr />
<h2> <span>Step 2 -</span> Launch Your First Server Machine</h2>
<p> Our server setup will consist of two parts: </p>
<ul>
<li>Application server hosted on Amazon&#8217;s Elastic Computing Cloud (EC2), running Apache and PHP, with WordPress installed on it.</li>
<li> MySQL database hosted on Amazon&#8217;s Relational Database Service (RDS).</li>
</ul>
<p> Another cheaper, but more difficult, option would be to manually install the MySQL server on the same machine with Apache and PHP. In this tutorial, I decided to go with the Relational Database Service because of its ease of use, as well as the fact that, this way, Amazon will take care of backups and maintenance for the database, and you won&#8217;t have to worry about that level of additional security. </p>
<p> Let&#8217;s start by creating our first application server instance. </p>
<p> Click on the EC2 tab in the <a href="https://console.aws.amazon.com/s3/home">AWS Management Console</a>. As this is your first time using the EC2 service, you will need to separately sign up for it. Click on the &#8220;Sign Up For Amazon EC2&#8243; button: </p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/981_wordpressCloud/2.jpg" border="0"></div>
<p> As a special step, Amazon will verify your identity by placing a call to your phone. The whole process is automated: you type a code from the web page into your phone and, once the system has verified that the codes match, you will be redirected to the next page. </p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/981_wordpressCloud/3.jpg" border="0"></div>
<p> When you are finished with the sign up process, return to the Management Console and the EC2 tab. You will see a page that looks like this. Click on the &#8220;Launch Instance&#8221; button. </p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/981_wordpressCloud/4.jpg" border="0"></div>
<p> A popup with a list of Amazon Machine Images (AMIs) opens.
</p>
<blockquote>
<p>AMIs are snapshots of running computers.</p>
</blockquote>
<p> Most consist of an operating system and a few utilities, but you can create AMIs with as much complexity as you wish &#8212; even containing your full application, ready to be started on a virtual machine with a click of a button. </p>
<p> We will pick the most basic option: &#8220;Basic 32-bit Amazon Linux AMI 1.0.&#8221; Click on &#8220;Select&#8221; next to the AMI and you are ready to go. </p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/981_wordpressCloud/5.jpg" border="0"></div>
<p> After selecting the AMI, our next step is to decide what kind of hardware we will use to run it. Depending on whether you picked a 32-bit or a 64-bit AMI, you will see a different list, the 32-bit AMIs offering the cheaper options. </p>
<p> For testing, we don&#8217;t need much memory or processing power, so we will start with a Micro instance. Select the instance type and click &#8220;Continue.&#8221; </p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/981_wordpressCloud/6.jpg" border="0"></div>
<p> In the next screen, the defaults do just fine. Click &#8220;Continue.&#8221; </p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/981_wordpressCloud/7.jpg" border="0"></div>
<p> When you have many machines with different roles, it&#8217;s easy to get lost with the machines and end up spending a lot of time searching for the right machine. Naming the machines helps a lot. In our case, naming is not too important, as we will run only one EC2 instance, but let&#8217;s give it a name anyhow. Enter your desired name and click &#8220;Continue.&#8221; </p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/981_wordpressCloud/8.jpg" border="0"></div>
<p> Next, you will be asked to create a key pair file for securely connecting to the machine. The key replaces a password when connecting to the machine with SSH. Name your key pair file, and click on &#8220;Create &#038; Download your Key Pair.&#8221; Copy the key pair file to a safe location (A good place, if you are on a Unix system such as Mac OSX or Linux, is <code>~/.ssh</code>). After copying the file, change its permissions to <code>400</code>: </p>
<pre name="code" class="js"> chmod 400 wordpress_demo.pem </pre>
<p> If you are using Windows, you probably use PuTTY for SSH. PuTTY uses its own key format (<code>ppk</code>), so you will need to convert the key to that format by using the Puttygen tool available at the <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html">PuTTY download page</a>. </p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/981_wordpressCloud/9.jpg" border="0"></div>
<p> After you&#8217;ve created the key pair, you will still be asked to configure the firewall for your new machine. By default, no one is allowed to connect to the machine &#8212; every port is closed. Let&#8217;s open ports <code>22</code> (SSH) and <code>80</code> (HTTP), so we can configure the machine over SSH and access the blog from a browser. Select the type of connection from the drop down list at the bottom of the popup and click on &#8220;Add Rule.&#8221; When you are done with the setup, click &#8220;Continue.&#8221; </p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/981_wordpressCloud/10.jpg" border="0"></div>
<p> Review the configuration, and, if everything appears to be correct, click &#8220;Launch.&#8221; </p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/981_wordpressCloud/11.jpg" border="0"></div>
<p> Now the machine is launching! Close the popup to return to the dashboard. At first, you&#8217;ll notice that the instance&#8217;s status is set to &#8220;<em>pending</em>,&#8221; and within a couple of minutes it switches to &#8220;<em>running</em>.&#8221; This means the server is up and running &#8212; you can start using it. </p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/981_wordpressCloud/12.jpg" border="0"></div>
<p> When the machine is running, it can be accessed through the ports you defined in the firewall configuration. Let&#8217;s use SSH to connect to the machine and finish its setup by installing Apache, PHP, the MySQL extension to PHP, and finally WordPress. </p>
<hr />
<h2> <span>Step 3 -</span> Install Required Server Software</h2>
<p> Right click on the name of the machine, and select &#8220;Connect&#8221; from the drop down list. A popup with an SSH command will open. </p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/981_wordpressCloud/13.jpg" border="0"></div>
<p> Highlight the command, and copy it to a console if you are using a Mac or a Unix machine. The command will be similar to the following: </p>
<pre name="code" class="js"> ssh -i wordpress_demo.pem root@ec2-....compute-1.amazonaws.com </pre>
<p> If you saved your <code>pem</code> key to <code>~/.ssh</code>, update the path in the command. Also, you&#8217;ll need to change <code>root</code> into <code>ec2-user</code> &#8212; Amazon hasn&#8217;t yet updated the command to match its new AMI setups that don&#8217;t allow connecting with the root user. </p>
<p> If you are on Windows, or prefer to use a more graphical SSH application, simply copy the name of the machine and open it in your SSH application of choice. Remember to use the user name <code>ec2-user</code> and the related key pair file (<code>wordpress_demo.pem</code>). </p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/981_wordpressCloud/14.jpg" border="0"></div>
<p> Once logged in, you can use the virtual machine just as you would use any Linux machine. </p>
<p> To install software, we will use an easy to use installer called Yum. First, to install the Apache web server, type the following command: </p>
<pre name="code" class="js"> sudo yum install httpd </pre>
<p> The installer asks you to confirm the package to install and possibly some other steps as well. Reply with &#8220;<em>Y</em>&#8221; to every question, and, in no time at all, you will have Apache installed. </p>
<p> Next up, PHP: </p>
<pre name="code" class="js"> sudo yum install php </pre>
<p> And the same for the MySQL extensions: </p>
<pre name="code" class="js"> sudo yum install php-mysql </pre>
<p> That&#8217;s it: the setup is done and we are ready to test Apache. Start it with this command (you can later replace &#8220;<code>start</code>&#8221; with &#8220;<code>stop</code>&#8221; or &#8220;<code>restart</code>&#8221; depending on what you want the web server to do): </p>
<pre name="code" class="js"> sudo /etc/init.d/httpd start </pre>
<p> The web server is up, and you can test it by copying the URL of the machine to your browser: </p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/981_wordpressCloud/15.jpg" border="0"></div>
<h2> <span>Step 4 -</span> Create the Database Machine</h2>
<p> Before installing WordPress, we still need a database. Setting up a database using RDS is as easy as entering some values to a couple of settings screens and pressing a few buttons, so let&#8217;s get started. </p>
<p> In your AWS console, switch to the RDS tab. As you have never used the service before, you will be asked to enable it. This time, the process is much faster and simpler than when you enabled EC2. Click on &#8220;Sign Up For Amazon RDS&#8221; to get started. </p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/981_wordpressCloud/16.jpg" border="0"></div>
<p> Follow the process through and, when you are finished, head back to the RDS tab in the AWS console. The screen you will see looks a lot like the EC2 console we used in the previous step. Click &#8220;Launch DB Instance.&#8221; </p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/981_wordpressCloud/17.jpg" border="0"></div>
<p> In the popup that opens, you can choose the properties for the database server to start, such as the server instance and storage space to allocate. Let&#8217;s pick the smallest values as they are more than enough for our simple test. </p>
<p> Pick a name for you database server and the root user on it. I used &#8220;<code>wordpress-db</code>&#8221; as the database server name and &#8220;<code>root</code>&#8221; / &#8220;<code>rootpass</code>&#8221; as master login. Not the most secure of options, mind you, but this machine is not intended to last for long, so it&#8217;s okay in this instance. </p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/981_wordpressCloud/18.jpg" border="0"></div>
<p> After setting up the database server information, you will be asked to define a default database to be created on the server. We will call it &#8220;<code>wordpress</code>&#8221; to follow the WordPress conventions. The rest of the settings on this screen can be left untouched. </p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/981_wordpressCloud/19.jpg" border="0"></div>
<p> On the next screen, you can define settings for database backups. For now, leave the values to their defaults and click &#8220;Continue.&#8221; </p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/981_wordpressCloud/20.jpg" border="0"></div>
<p> After verifying the settings, click &#8220;Launch DB Instance.&#8221; </p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/981_wordpressCloud/21.jpg" border="0"></div>
<p> Creating a database instance takes quite a bit longer than creating the EC2 instance, but after about five minutes of waiting, you should see the database instance as &#8220;available&#8221; on the instances tab. </p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/981_wordpressCloud/22.jpg" border="0"></div>
<p> Click on the instance to see more data about it, then copy the &#8220;<code>endpoint</code>&#8221; value. This is the URL of the database server that we will use in the WordPress setup. </p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/981_wordpressCloud/23.jpg" border="0"></div>
<p> There is one more step before we can move on to installing WordPress: we need to configure the firewall for this database so that the application server can access it. </p>
<p> Still on the RDS tab in the AWS console, click on &#8220;DB Security Groups.&#8221; You will see that there are no authorizations yet: </p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/981_wordpressCloud/24.jpg" border="0"></div>
<p> To give our application server access to the database, we need to authorize its security group to this database security group. Select &#8220;EC2 Instance&#8221; from the drop down list below &#8220;No Authorizations&#8221; and enter the name of the security group (&#8220;<code>wordpress_app_server</code>&#8220;) and your Amazon Account ID to the two text fields that appear next to the drop down list. </p>
<p> The account ID is hidden quite deep in the AWS settings: you&#8217;ll find it by first clicking the &#8220;Account&#8221; link at the top of the page, and then the &#8220;Security Credentials&#8221; link on the page that opens. </p>
<p> After you&#8217;ve entered the required information and clicked &#8220;Add,&#8221; you will see the security group as authorized. We are ready to install WordPress.</p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/981_wordpressCloud/25.jpg" border="0"></div>
<hr/>
<h2> <span>Step 5 -</span> Install WordPress</h2>
<p> If you are not connected to the application server anymore, open an SSH connection to it again. We&#8217;ll start by downloading WordPress on the machine. By default, Apache is configured to look for HTML files from <code>/var/www/html/</code>, so let&#8217;s download WordPress to that directory. </p>
<pre name="code" class="js"> cd /var/www/html </pre>
<p>To make things easier in the future, we will change <code>ec2-user</code> to be the owner of that directory:</p>
<pre name="code" class="js"> sudo chown ec2-user . </pre>
<p> You can download WordPress to your own computer and upload it from there using SCP, but I find it easier to download it directly to the Amazon machine using wget: </p>
<pre name="code" class="js"> wget http://wordpress.org/latest.zip </pre>
<p> This way, the WordPress package goes straight to its final location and all you need to do is to unzip it: </p>
<pre name="code" class="js"> unzip latest.zip </pre>
<p> We are about ready to start configuring the blog. As our last step in the command line, change permissions of the <code>wordpress</code> directory that was just created so that the installation script can create the <code>wp-config.php</code> file: </p>
<pre name="code" class="js"> chmod o+w wordpress </pre>
<p> Now, open the WordPress URL in your browser (The URL of the EC2 instance followed by <code>/wordpress</code>). Click on &#8220;Create a Configuration File&#8221; and then on the next page &#8220;Let&#8217;s go!&#8221; </p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/981_wordpressCloud/26.jpg" border="0"></div>
<p> You will end up on a page for entering the database settings. Enter the database name, user name and password, and the URL of the RDS instance. Then click &#8220;Submit.&#8221; </p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/981_wordpressCloud/28.jpg" border="0"></div>
<p> You are almost set. Configure the rest of the blog details to finish the installation and enjoy your newly created blog. </p>
<p> You have successfully installed WordPress in the cloud! </p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/981_wordpressCloud/29.jpg" width="600" border="0"></div>
<p> <!-- 600px or less --></p>
<hr/>
<h2> <span>Step 6</span> Stop Everything</h2>
<p> As I mentioned at the beginning of this tutorial, AWS billing is based on the hours of usage, so to make sure you are not billed for time that you are not really using, make sure to stop everything once you are done testing. </p>
<p> First, stop the EC2 instance by selecting it from the admin, right clicking on it and choosing &#8220;Stop.&#8221; If you later decide to start the machine again, all you need is to click on &#8220;Start&#8221; in the same drop down list and the machine will resume from where you left it. </p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/981_wordpressCloud/30.jpg" border="0"></div>
<p> Stopping the database is just as easy, with the exception that you can&#8217;t resume the database again. That&#8217;s not so nice, but luckily you have the choice to save a snapshot of the data while stopping the database. You can later use this data to recreate the database setup whenever you need it again. </p>
<p> On the RDS tab, right click on your database instance and select &#8220;Delete.&#8221; </p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/981_wordpressCloud/31.jpg" border="0"></div>
<p> Verify that everything is stopped and log out of the AWS console. Your blog is gone, just as fast as it started. </p>
<p>Thanks for reading! I hope you learned a bit!</p>
]]></content:encoded>
			<wfw:commentRss>http://net.tutsplus.com/tutorials/wordpress/deploy-your-wordpress-blog-to-the-cloud/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scaling WordPress for High-Traffic</title>
		<link>http://net.tutsplus.com/articles/scaling-wordpress-for-hi-traffic/</link>
		<comments>http://net.tutsplus.com/articles/scaling-wordpress-for-hi-traffic/#comments</comments>
		<pubDate>Tue, 01 Mar 2011 17:15:53 +0000</pubDate>
		<dc:creator>Ryan Allen</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Lectures]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://net.tutsplus.com/?p=18566</guid>
		<description><![CDATA[<a href="http://rss.buysellads.com/click.php?z=1260013&#38;k=d754f1e9ba63a736ba8ff5ece958f7dd&#38;a=18566&#38;c=264739686" target="_blank"><img src="http://rss.buysellads.com/img.php?z=1260013&#38;k=d754f1e9ba63a736ba8ff5ece958f7dd&#38;a=18566&#38;c=264739686" border="0" alt="" /></a>Just because you didn’t get to go to that awesome conference doesn’t mean that you can’t still watch the lectures! Each week, we feature one recommended web development lecture on Nettuts+. This talk, presented by Envato&#8217;s very own developer extraordinaire, Ryan Allen, will detail some of the potential pitfalls and solutions when maintaining massive WordPress [...]]]></description>
			<content:encoded><![CDATA[<a href='http://rss.buysellads.com/click.php?z=1260013&k=d754f1e9ba63a736ba8ff5ece958f7dd&a=18566&c=107585435' ><img src='http://rss.buysellads.com/img.php?z=1260013&k=d754f1e9ba63a736ba8ff5ece958f7dd&a=18566&c=107585435' border='0' alt='' /></a><p>Just because you didn’t get to go to that awesome conference doesn’t mean that you can’t still watch the lectures! Each week, we feature one <a href="http://net.tutsplus.com/category/articles/lectures/" >recommended web development lecture</a> on Nettuts+.</p>
<p>This talk, presented by <a href="http://www.envato.com">Envato&#8217;s</a> very own developer extraordinaire, <a href="http://twitter.com/ryanfaceryan">Ryan Allen</a>, will detail some of the potential pitfalls and solutions when maintaining massive WordPress blogs, like <a href="http://www.tutsplus.com">Tuts+</a>. </p>
<p><span id="more-18566"></span></p>
<div class="tutorial_image">
<embed src="http://blip.tv/play/AYKnsiYC" type="application/x-shockwave-flash" width="600" height="488" allowscriptaccess="always" allowfullscreen="true"></embed></p>
<div>
<p>Please note that Ryan has a unique (but hilarious) sense of humor. </p>
</div>
</div>
<h3> Presentation Links </h3>
<ul>
<li><a href="http://rockablepress.com/books/blog-business/">How to Build a Successful Blog Business</a></li>
<li><a href="http://scalingwp.com/">ScalingWP.com</a></li>
<li><a href="http://twitter.com/scalingwp">@scalingwp</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://net.tutsplus.com/articles/scaling-wordpress-for-hi-traffic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Innovative Uses of WordPress Post Types and Taxonomies</title>
		<link>http://net.tutsplus.com/tutorials/wordpress/innovative-uses-of-wordpress-post-types-and-taxonomies/</link>
		<comments>http://net.tutsplus.com/tutorials/wordpress/innovative-uses-of-wordpress-post-types-and-taxonomies/#comments</comments>
		<pubDate>Mon, 07 Feb 2011 02:46:26 +0000</pubDate>
		<dc:creator>Adam Murray</dc:creator>
				<category><![CDATA[custom type]]></category>
		<category><![CDATA[taxonomy]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[wp 3.0]]></category>

		<guid isPermaLink="false">http://net.tutsplus.com/?p=18116</guid>
		<description><![CDATA[<a href="http://rss.buysellads.com/click.php?z=1260013&#38;k=d754f1e9ba63a736ba8ff5ece958f7dd&#38;a=18116&#38;c=1073046320" target="_blank"><img src="http://rss.buysellads.com/img.php?z=1260013&#38;k=d754f1e9ba63a736ba8ff5ece958f7dd&#38;a=18116&#38;c=1073046320" border="0" alt="" /></a>With the release of WordPress 3.0, two great ways to better organize and display content were introduced: post types and taxonomies. These two advances improve WordPress&#8217; role as an all-around content management system, and they continue to prove that WP is not just a blog platform. When 3.1 releases with post formats, it will be [...]]]></description>
			<content:encoded><![CDATA[<a href='http://rss.buysellads.com/click.php?z=1260013&k=d754f1e9ba63a736ba8ff5ece958f7dd&a=18116&c=1717195238' ><img src='http://rss.buysellads.com/img.php?z=1260013&k=d754f1e9ba63a736ba8ff5ece958f7dd&a=18116&c=1717195238' border='0' alt='' /></a><p>With the release of WordPress 3.0, two great ways to better organize and display content were introduced: <strong>post types and taxonomies</strong>.  These two advances improve WordPress&#8217; role as an all-around content management system, and they continue to prove that WP is not just a blog platform.  When 3.1 releases with post formats, it will be imperative that you understand how to use and implement post types and taxonomies.</p>
<p><span id="more-18116"></span></p>
<hr />
<h2>What We&#8217;re Going to Cover</h2>
<p>In this tutorial, I will talk you through the following:</p>
<ul>
<li>Overview of post types and taxonomies in WordPress 3.0</li>
<li>How to integrate post types and taxonomies into your themes</li>
<li>Real-world examples of how to use post types and taxonomies in innovative ways within your projects</li>
</ul>
<p>By the time you&#8217;ve completed these steps, I hope to fuel your projects by examining other awesome ways to integrate these organizational elements in WordPress.	</p>
<hr />
<h2>A Quick Overview of WordPress Post Types</h2>
<blockquote><p>When you think of post types, the important word to remember is <strong>organization</strong>.  The post type itself will not add really any functionality, but it allows us to better organize WordPress content and build admin dashboards that are more specific to the type of site that we are working with.</p>
</blockquote>
<p>Here are some important things to remember when working with post types:</p>
<ul>
<li>When you create a new post type, a new upper level nav element will appear the main left side admin menu.  From there, all of the standard post and page editors are available.</li>
<li>The URL string for a new post type will be : http://yoursite.com/{post-type}/{title}/.</li>
<li>You can create post type archive pages just like you do with categories, and you can even create special template files by creating an archive-{post-type}.php file.</li>
</ul>
<blockquote>
<p>
&#8220;In the same way that posts are shown on their own archive with archive.php, custom post types will use archive-{posttype}.php.&#8221;
</p>
</blockquote>
<p>For other info on integrating post types, querying post types, and overall functions, visit the codex <a href="http://codex.wordpress.org/Post_Types">here</a>.</p>
<hr />
<h2>Integrating Post Types via Functions.php</h2>
<p>Integrating post types is simply a matter of including the <code>register_post_type</code> function.  Once you have included this in your functions.php file, your nav menu should go from something like this:</p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/912_wpPostTypes/wordpress_nav_orig.jpg" alt="our original wordpress menu" width="200" height="365" /></div>
<p>to this:</p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/912_wpPostTypes/wordpress_new_post_type.jpg" alt="our new wordpress menu with our post type" width="200" height="297"/></div>
<p>In order to create custom post types, open your template&#8217;s <code>functions.php</code> file in an editor, and place the following function within the file:</p>
<pre name="code" class="php">

function create_post_type() {
	register_post_type( 'mysite_reviews',
		array(
			'labels' => array(
				'name' => __( 'Reviews' ),
				'singular_name' => __( 'Review' )
			),
		'public' => true,
        'menu_position' => 5,
        'rewrite' => array('slug' => 'reviews')
		)
	);
}

add_action( 'init', 'create_post_type' );
</pre>
<p>Broken down, this adds the function <code>create_post_type</code>, and registers the post type <strong>mysite_reviews</strong>,</p>
<pre name="code" class="php">

add_action( 'init', 'create_post_type' );
function create_post_type() {
	register_post_type( 'mysite_reviews',
</pre>
<p>You may wonder why I&#8217;ve named the post_type <strong>mysite_reviews</strong>, and not just <strong>reviews</strong>.  I made the name more conspicuous in order to make sure that my post type wouldn&#8217;t interfere with custom post type names from other plugins or themes.</p>
<blockquote><p>Another friendly reminder, your custom post types must not exceed 20 characters, as that is limit of the database column.</p>
</blockquote>
<p>Here is a summary of the important post type parameters I&#8217;ve set above:</p>
<ul>
<li><strong>labels</strong> &#8211; WordPress allows us to label everything from the post type&#8217;s name to the label for adding new posts.  A complete list can be found <a href="http://codex.wordpress.org/Function_Reference/register_post_type">here</a>.  In the above function, I labeled the name of the post type and its singular name.</li>
<li><strong>public</strong> &#8211; If set to true</li>
<li><strong>menu_position</strong> &#8211; I set this to 5, which will place the post type directly under &#8220;Posts&#8221;.  The other placements are as follows: <strong>null</strong> (below Comments), <strong>0</strong> (below Media), <strong>20</strong> (below Pages), <strong>60</strong> (below first separator) and <strong>100</strong> (below second separator) </li>
<li><strong>rewrite</strong> &#8211; So that our actual term &#8220;mysite_reviews&#8221; doesn&#8217;t get put in the URL, we set the slug to &#8220;reviews&#8221; which will be much better in the long run for our visitors, links, and SEO.</li>
</ul>
<h3>For More Information</h3>
<p>A full list of parameter arguments for post types can be found <a href="http://codex.wordpress.org/Function_Reference/register_post_type">here</a>.</p>
<hr />
<h2>Displaying Post Types in WordPress Themes</h2>
<p>Since WordPress post types are simply an extension of the existing classification system, displaying them in a theme is quite similar to what is already in place.  There are currently three primary ways to display custom post types in your themes:</p>
<ul>
<li><strong>Post Query</strong></li>
<li><strong>Single Post Template</strong></li>
<li><strong>Archive Template</strong></li>
</ul>
<h3>Displaying via Post Query</h3>
<p>To display the new post type <code>mysite_reviews</code>, you will want to open up the template file that you would like to display it on (in my case, I usually create a custom <code>home.php</code> for templates), and enter the following code:</p>
<pre name="code" class="php">
$args = array( 'post_type' => 'mysite_reviews', 'posts_per_page' => 10 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
	the_title();
	echo '&lt;div class="entry-content"&gt;';
	the_excerpt();
	echo '&lt;/div&gt;';
endwhile;
</pre>
<p>This simply creates a new WordPress loop that will display the title and excerpt from the 10 most recent entries in the <code>mysite_reviews</code> post type.<br />
<h3>Displaying via Single Post Template</h3>
<p>Just as you can customize the way individual posts are displayed via a theme&#8217;s single.php file, you can customize the way your individual post type entries are displayed. The easiest way to do this is to create a duplicate of your theme&#8217;s single.php file and rename it to <code>single-{posttypename}.php</code>.  From there, you can customize that file to your specs.  Using the example  from above, we would need a single post template named <code>single-mysite_reviews.php</code>.</p>
<h3>Displaying by Archive Template</h3>
<p>While this feature will not be available until WP 3.1 releases, post types can also be displayed archive-style by creating a file in your theme named archive-{posttypename}.php.  So, if we were creating an archive for the post type, we would create an archive template named <code>archive-mysite_reviews.php</code> and place it within our template folder.</p>
<blockquote><p>With custom post type templating, custom theme creators can more easily create subscription and membership sites by restricting the content on these specific posts and pages to specified user groups.</p></blockquote>
<hr />
<h2>A Quick Overview of WP Taxonomies</h2>
<p>I won’t go into too much detail here as Paul Kaiser has already written a great overview of taxonomies and the code that is involved to implement the function (see the tutorial <a href="http://net.tutsplus.com/tutorials/wordpress/introducing-wordpress-3-custom-taxonomies/">here</a>).  The key word to remember when thinking about taxonomies is <strong>classification</strong>.  They are similar to tags, but allow for deeper, more content-specific classification. </p>
<blockquote class="pullquote pqRight"><p>In truth, they are an extremely powerful way to group various items in all sorts of ways.</p>
</blockquote>
<p>For example, say that I have use the <strong>Reviews</strong> post type from above.  Because I will definitely want to classify that broad post type, I can create taxonomies like:</p>
<ul>
<li>Movie Reviews</li>
<li>Book Reviews</li>
<li>Product Reviews</li>
</ul>
<p>With custom taxonomies, I could even go deeper into classifying the above taxonomies.  I could go into movie genres, book authors, and product markets.  Again, together with post types, these greatly increase WordPress&#8217; content management capabilities.</p>
<hr />
<h2>Integrating Taxonomies via Functions.php</h2>
<p>Overall, taxonomies are pretty easy to implement in your <code>functions.php</code> file.  Remember, you can go hierarchical with them or treat them like tags, so the more complex you want the greater the difficulty.  Either way,  here is a quick rundown of how to incorporate these into your theme.</p>
<p>Again, open up your functions.php file and insert the following code:</p>
<pre name="code" class="php">

    function movie_taxonomy() {
       register_taxonomy(
        'movie_review',
        'mysite_reviews',
        array(
            'hierarchical' => true,
            'label' => 'Movie Review',
            'query_var' => true,
            'rewrite' => array('slug' => 'movie-reviews')
        )
    );
    }

    add_action( 'init', 'movie_taxonomy' );
</pre>
<p>To break this down, first we give the taxonomy a formal name (&#8220;movie_review&#8221;), and we place it under the post type &#8220;mysite_reviews&#8221;, which we created earlier.</p>
<pre name="code" class="php">

function movie_taxonomy() {
   register_taxonomy(
	'movie_review',
	'mysite_reviews',
</pre>
<p>Then we pass these values:</p>
<pre name="code" class="php">

	array(
            'hierarchical' => true,
            'label' => 'Movie Review',
            'query_var' => true,
            'rewrite' => array('slug' => 'movie-reviews')
        )
</pre>
<p>This supplies the following arguments:</p>
<ul>
<li><strong>hierarchical</strong> &#8211; When set to &#8220;true&#8221;, the taxonomy will act more like a category.  There can be parent taxonomies and nested taxonomies allowing for greater depth of classification.  When set to &#8220;false&#8221;, they act like just like tags.</li>
<li><strong>label</strong> &#8211; As with the post types above, this is the label that the taxonomy will publicly recieve.</li>
<li><strong>query_var</strong> &#8211; When set to &#8220;true&#8221; this taxonomy becomes a queryable element.</li>
<li><strong>rewrite</strong> &#8211; This sets the URL rewrite.  Now posts in this taxonomy will be displayed as http://mysite.com/movie-reviews/{post title}/.</li>
</ul>
<p>The end result within our admin nav should look like this:</p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/912_wpPostTypes/taxonomy_review_nav.jpg" alt="New WordPress taxonomy in admin dashboard navigation" width="200" height="117"/></div>
<p>Furthermore, we can dive into that interface and add more classification categories and structure.  That interface looks similar to the category interface that you may already be familiar with.</p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/912_wpPostTypes/taxonomy_movie_review.jpg" alt="Taxonomy user interface" width="350" height="275"/></div>
<p>From this interface, you can edit the slugs of the various categories within your taxonomy, create new categories, and determine parent and child categories.</p>
<h3>For More Information</h3>
<p>A full list of parameter arguments for taxonomies can be found <a href="http://codex.wordpress.org/Function_Reference/register_taxonomy">here</a>.</p>
<hr />
<h2>Displaying Taxonomies in WordPress Themes</h2>
<p>There are currently three primary ways to display custom post types in your themes:</p>
<ul>
<li><strong>Taxonomy Cloud</strong></li>
<li><strong>Custom Taxonomy Query</strong></li>
<li><strong>Custom Taxonomy List</strong></li>
</ul>
<h3>Taxonomy Cloud</h3>
<p>Just as there are tag clouds, there are taxonomy clouds.  To make it easy, both tags and clouds use the <code>wp_tag_cloud</code> function.  In order to display an array of taxonomy categories in a cloud, we would use the following code:</p>
<pre name="code" class="php">
 &lt;?php
        wp_tag_cloud( array( 'taxonomy' => 'taxonomy_name_1','taxonomy_name_2' ) );
?&gt;
</pre>
<p>For more information about the function and its parameter arguments, visit the <a href="http://codex.wordpress.org/Function_Reference/wp_tag_cloud">codex</a>.</p>
<h3>Custom Taxonomy Query</h3>
<p>Taxonomies can also be included in custom queries just like we did with post types above.  For example, to display content from the taxonomy <code>movie_genre</code>, we would need to insert the following code into our template file:</p>
<pre name="code" class="php">
    $args = array(
	'tax_query' => array(
		'taxonomy' => 'movie_genre',
		'field' => 'slug',
        'terms' => 'comedy'
		)
);
query_posts( $args );
    </pre>
<p>First, we use the argument <code>tax_query</code> so that we can pass parameters that will allow us to query by slug or terms and return more accurate query results.  In this example, we displayed posts tagged as &#8220;comedy&#8221; within the custom taxonomy &#8220;movie_genre&#8221;.  Once again, like we did with post types, we can limit the number of posts that this query returns.</p>
<h3>Custom Taxonomy Lists</h3>
<p>To display a comma-delineated list of posts by taxonomy, we simply need to put the following somewhere in the loop:</p>
<pre name="code" class="php">

    	&lt;?php the_terms( $post->ID, '{taxonomy name}', '{Displayed Title}: ', ', ', ' ' ); ?&gt;
</pre>
<p>There are other display options for this list, and the parameters can be found <a href="http://codex.wordpress.org/Function_Reference/the_terms">here</a>.</p>
<hr />
<h2>Using Post Types and Taxonomies in Your Next Project</h2>
<p>Now that we have the nuts and bolts, I think &#8220;Why do I care about these things?&#8221; is a really fair question.  The possibilities with post types and taxonomies, especially working with clients that are often too busy to manage the intricacies of a site, is endless.   This, in my opinion, saves time over creating new admin functions and updating plugins, and opens doors to new possibilities with much less work (and coding) involved.</p>
</p>
<p>Below are some ideas that I had about how to integrate these into actual work:</p>
<h3><span>1.</span> Review Sites</h3>
<p>First, a review site could benefit from the custom templating options listed above (single and archive)  </p>
<p>Here are some more post types and taxonomies that you could implement on a review site:</p>
<ul>
<li><strong>Post Type -</strong> Movie Reviews</li>
<li><strong>Taxonomies -</strong> Genre, Actor, Director
</li>
<li><strong>Post Type -</strong> Book Reviews</li>
<li>	<strong>Taxonomies -</strong> Genre, Author, Publisher
</li>
<li><strong>Post Type -</strong> Product Reviews</li>
<li>	<strong>Taxonomies -</strong> Product Category, Price
</li>
</ul>
<h3><span>2.</span> Real Estate Listing Sites</h3>
<p>While there are some good templates for real estate listing sites, post types and taxonomies let creative people  make custom templates that can easily be maintained by clients and webmasters alike. Here are just a few ideas to use in your next project:</p>
<ul>
<li><strong>Post Type -</strong> Listings</li>
<li><strong>Taxonomies -</strong> Area, Agent, Price, Rooms
</li>
<li><strong>Post Type -</strong> Agents</li>
</ul>
<h3><span>3.</span> Event Listings</h3>
<p>One thing that WordPress really lacks (in my opinion) is a good event management system. Post types and taxonomies could easily take care of that by offering a system to classify monthly events by location, day, or any other system you can think of.</p>
<h3><span>4.</span> Subscription Sites</h3>
<p>With the creation of a new post type and template, you could create a custom, premium category for your blog or website and integrate a payment gateway to create your very own membership site. </p>
<h3><span>5.</span> E-commerce</h3>
<p>By creating a product post type and template, you could easily add and display products for sale on your site.  In addition, taxonomies would allow for easy product organization.</p>
<hr />
<h2>Where Do We Go From Here?</h2>
<p>I hope this tutorial has explained post types and taxonomies in WordPress 3.0, and why they are an extremely valuable resource to implement in your projects.  I know that there are many advocates of plugins (and I am a plugin author myself), but I hope that I have made the case that implementing these things is a very simple task and one that will save time for both you and your client in the long run.</p>
</p>
<p>The list of ideas above is a small one at best, so I would love to hear how you have implemented them into your projects or maybe some other uses that I didn&#8217;t list.</p>
<p>Thank you so much for reading!</p>
]]></content:encoded>
			<wfw:commentRss>http://net.tutsplus.com/tutorials/wordpress/innovative-uses-of-wordpress-post-types-and-taxonomies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick Tip: How to Target WordPress Sticky Posts</title>
		<link>http://net.tutsplus.com/tutorials/wordpress/quick-tip-how-to-target-wordpress-sticky-posts/</link>
		<comments>http://net.tutsplus.com/tutorials/wordpress/quick-tip-how-to-target-wordpress-sticky-posts/#comments</comments>
		<pubDate>Tue, 25 Jan 2011 04:31:44 +0000</pubDate>
		<dc:creator>Jeffrey Way</dc:creator>
				<category><![CDATA[sticky posts]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://net.tutsplus.com/?p=17820</guid>
		<description><![CDATA[<a href="http://rss.buysellads.com/click.php?z=1260013&#38;k=d754f1e9ba63a736ba8ff5ece958f7dd&#38;a=17820&#38;c=1694835380" target="_blank"><img src="http://rss.buysellads.com/img.php?z=1260013&#38;k=d754f1e9ba63a736ba8ff5ece958f7dd&#38;a=17820&#38;c=1694835380" border="0" alt="" /></a>As of WordPress 2.7, we can now assign &#8220;sticky posts.&#8221; This feature affords us the ability to &#8220;pin&#8221; postings to the top of our blog. But, how can we specifically target these sorts of postings from within our stylesheet? Notice the pretty ribbon that&#8217;s attached to this particular posting? That&#8217;s thanks to stickied posts! Adjust [...]]]></description>
			<content:encoded><![CDATA[<a href='http://rss.buysellads.com/click.php?z=1260013&k=d754f1e9ba63a736ba8ff5ece958f7dd&a=17820&c=125663726' ><img src='http://rss.buysellads.com/img.php?z=1260013&k=d754f1e9ba63a736ba8ff5ece958f7dd&a=17820&c=125663726' border='0' alt='' /></a><p>As of WordPress 2.7, we can now assign &#8220;sticky posts.&#8221; This feature affords us the ability to &#8220;pin&#8221; postings to the top of our blog. But, how can we specifically target these sorts of postings from within our stylesheet?</p>
<p><span id="more-17820"></span></p>
<p>
<em>Notice the pretty ribbon that&#8217;s attached to this particular posting? That&#8217;s thanks to stickied posts! </em>
</p>
<div class="tutorial_image">
<iframe title="YouTube video player" class="youtube-player" type="text/html" width="600" height="375" src="http://www.youtube.com/embed/9NqNIaEKxXo?hd=1" frameborder="0" allowFullScreen></iframe></p>
<div>Adjust the resolution to <strong>720</strong> for maximum clarity. </div>
<p><span><a href="http://www.youtube.com/user/nettutsplus">Subscribe to our YouTube page to watch all of the video tutorials!</a></span>
</div>
]]></content:encoded>
			<wfw:commentRss>http://net.tutsplus.com/tutorials/wordpress/quick-tip-how-to-target-wordpress-sticky-posts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress Shortcodes: The Right Way</title>
		<link>http://net.tutsplus.com/tutorials/wordpress/wordpress-shortcodes-the-right-way/</link>
		<comments>http://net.tutsplus.com/tutorials/wordpress/wordpress-shortcodes-the-right-way/#comments</comments>
		<pubDate>Tue, 28 Dec 2010 17:27:33 +0000</pubDate>
		<dc:creator>Siddharth</dc:creator>
				<category><![CDATA[custom theme]]></category>
		<category><![CDATA[shortcodes]]></category>
		<category><![CDATA[themeforest]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[usability]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[wp]]></category>

		<guid isPermaLink="false">http://net.tutsplus.com/?p=17165</guid>
		<description><![CDATA[<a href="http://rss.buysellads.com/click.php?z=1260013&#38;k=d754f1e9ba63a736ba8ff5ece958f7dd&#38;a=17165&#38;c=1098826344" target="_blank"><img src="http://rss.buysellads.com/img.php?z=1260013&#38;k=d754f1e9ba63a736ba8ff5ece958f7dd&#38;a=17165&#38;c=1098826344" border="0" alt="" /></a>One of the primary reasons why WordPress is the most popular CMS platform available is the sheer level of customizability that it brings to the table. Today, we&#8217;ll review the process of integrating one of those popular features, shortcodes, in the most user friendly way possible, into our theme. A Visual Crash-Course in Shortcodes Subscribe [...]]]></description>
			<content:encoded><![CDATA[<a href='http://rss.buysellads.com/click.php?z=1260013&k=d754f1e9ba63a736ba8ff5ece958f7dd&a=17165&c=1825292460' ><img src='http://rss.buysellads.com/img.php?z=1260013&k=d754f1e9ba63a736ba8ff5ece958f7dd&a=17165&c=1825292460' border='0' alt='' /></a><p>One of the primary reasons why WordPress is the most popular CMS platform available is the sheer level of customizability that it brings to the table. Today, we&#8217;ll review the process of integrating one of those popular features, <a href="http://codex.wordpress.org/Shortcode">shortcodes</a>, in the most user friendly way possible, into our theme.</p>
<p><span id="more-17165"></span></p>
<hr />
<h2>A Visual Crash-Course in Shortcodes </h2>
</h2>
<div class="tutorial_image"><object width="600" height="338"><param name="movie" value="http://www.youtube.com/v/msFmkKXmlmM?fs=1&amp;hl=en_US&amp;hd=1&amp;color1=0x3a3a3a&amp;color2=0x999999"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/msFmkKXmlmM?fs=1&amp;hl=en_US&amp;hd=1&amp;color1=0x3a3a3a&amp;color2=0x999999" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="600" height="338"></embed></object></p>
<div><a href="http://www.youtube.com/user/nettutsplus">Subscribe to our YouTube page to watch all of the video tutorials!</a><br /><a href="http://nettuts.blip.tv/">Watch longer Screencasts on our Blip channel. </a> </div>
</div>
<hr />
<h2>A Word From the Author</h2>
<p>Even though there are a few trillion options to choose from, WordPress has comfortably taken the crown as the king of CMSs and blogging platforms with its incredible flexibility. A shortcode is one of those features that ratchet up the user friendliness of the system.</p>
<p>However, most implementations still require you to remember the shortcode itself. When you&#8217;ve created a masterpiece of a theme, the usability shouldn&#8217;t really lag behind.  I&#8217;ll show you how to create shortcodes and then integrate it with the editor itself, so the user doesn&#8217;t have to go poring through your docs just to remember the correct syntax to embed a button. Intrigued? Let&#8217;s get started right away!</p>
<hr />
<h2>What Are These Shortco-whamathingies?</h2>
<p>It&#8217;s called a <strong>shortcode</strong> and it has been part of the base WordPress installation since it hit version 2.5. Basically, these are similar to the <em>bbcodes</em> used on popular message board software: lightweight markup used to format content. </p>
<p>Here, you can define your own codes to use within your theme. Unlike BBCodes, though, shortcodes are primarily used to shield the user from tedious markup and possible errors. By using a shortcode, for say, a button, the user doesn&#8217;t have to remember the complicated markup that needs to be input to create the button. Overall, it&#8217;s quite a boost to a theme&#8217;s usability and possibly, noob friendliness.</p>
<hr />
<h2>ShortCode Variations</h2>
<p>If you&#8217;re unfamiliar with the concept of a BBCode, and by extension, shortcode, this is how the simplest version looks:</p>
<pre name="code" class="js">
[my-gallery]
</pre>
<p>If you&#8217;ve ever embedded a gallery with WordPress, you&#8217;ve already used a shortcode!</p>
<p>There are two more variations you should also be familiar with.</p>
<pre name="code" class="js">
 [button]Content[/button]

 [link to="www.net.tutsplus.com"]NetTuts+[link]
</pre>
<p>We&#8217;ll implement each of these variations first before moving onto other, busier things.</p>
<p>Each shortcode implementation requires a two-step process:</p>
<ul>
<li><strong>1: </strong>Create the primary handler method</li>
<li><strong>2: </strong>Hook up the handler to WordPress</li>
</ul>
<p>Regardless of the complexity of the shortcode, the core steps remain the same.</p>
<hr />
<h2><span>Take 1:</span> Replacing Strings</h2>
<p>We&#8217;ll first learn how to implement the simplest shortcode possible. As a use case, let&#8217;s say you end each post with some common signing off text. Copying and pasting might be a simple approach, but you may feel like a luddite doing so. Let&#8217;s fix this with some WP niftiness!</p>
<blockquote><p>Unless otherwise noted, all of the code below goes into <em>functions.php</em></p></blockquote>
<h3><span>Step 1: </span>Create the Primary Function</h3>
<p>The primary function takes care of the core logic of your shortcode. We&#8217;ll need to create this first before proceeding.</p>
<pre name="code" class="php">
 function signOffText() {
    return 'Thank you so much for reading! And remember to subscribe to our RSS feed. ';
}
</pre>
<h3><span>Step 2:</span> Hook into WordPress</h3>
<p>The next step, as you may assume, is to hook into the WordPress system to associate the shortcode with this text. This is done using the <code>add_shortcode</code> method. </p>
<pre name="code" class="php">
add_shortcode('signoff', 'signOffText');
</pre>
<p>Yes, a single one-liner is all it takes. The first parameter defines the shortcode you&#8217;ll be using in the editor, while the the second points to the function we created a moment or so ago. </p>
<p><strong>Note:</strong> The <code>add_shortcode</code> method always comes after the handler method.</p>
<p>That should do it. Just type <code>[signoff]</code> into your editor and WordPress will dynamically replace the text as needed.</p>
<hr />
<h2><span>Take 2:</span> Wrapping Content</h2>
<p>Next up, we&#8217;re going to take a look at another variation: wrapping some content with some markup. You&#8217;d have to use it like so:</p>
<pre name="code" class="php">
[quote]Some text[/quote]
</pre>
<h3><span>Step 1: </span>Create the Primary Function</h3>
<p>The primary function has to be modified a little here. We&#8217;re noting that our function receives two parameters: attributes through the <code>atts</code> variable and the content itself through the <code>content</code> variable.</p>
<p>The next step is simply to return the markup wrapped around the selected text. </p>
<pre name="code" class="php">
function quote( $atts, $content = null ) {
	return '&lt;div class="right text"&gt;"'.$content.'"&lt;/div&gt;';
}
</pre>
<h3><span>Step 2:</span> Hook into WordPress</h3>
<p>This step remains the same:</p>
<pre name="code" class="php">
add_shortcode("quote", "quote");
</pre>
<p>I like to name my shortcodes exactly the same as the primary functions unless the naming gets unwieldy. You may have your own styles so feel free to change the naming scheme. There&#8217;s no accepted best practice.</p>
<hr />
<h2><span>Take 3:</span> Adding Attributes</h2>
<p>Finally, we&#8217;re going to take a look at adding attributes to the mix as well. You&#8217;d have to use it like so:</p>
<pre name="code" class="php">
[link to="www.net.tutsplus.com"]NetTuts+[link]
</pre>
<h3><span>Step 1: </span>Create the Primary Function</h3>
<p>The primary function needs to be refactored to handle all the new functionalities we&#8217;re bringing in.  First up, we merge the attributes passed in with the shortcode and the attributes we&#8217;re expecting. You can read up more on the process <a href="http://codex.wordpress.org/Function_Reference/shortcode_atts">here</a>.</p>
<p>The final step, as always, is simply to return the markup we want after filling it up appropriately. Here, I&#8217;ve used the data sent with the shortcode to fill in the anchor&#8217;s <code>href</code> attribute as well as content. </p>
<pre name="code" class="php">
function link($atts, $content = null) {
	extract(shortcode_atts(array(
		"to" =&gt; 'http://net.tutsplus.com'
	), $atts));
	return '&lt;a href="'.$to.'"&gt;'.$content.'&lt;/a&gt;';
}
</pre>
<h3><span>Step 2:</span> Hook into WordPress</h3>
<p>This step remains unchanged, but essential. Remember, without this, WordPress has no what to do with the shortcode.</p>
<pre name="code" class="php">
add_shortcode("link", "link");
</pre>
<hr />
<h2>Kicking Everything Up a Notch</h2>
<p>This is where you&#8217;d expect this tutorial to end but no, you&#8217;ve guessed wrong. As I mentioned earlier, shortcodes take away a lot of pain, but there are few gotchas. For one, the user has to remember the shortcodes he has at his disposal to make meaningful use of them.</p>
<p>If you have just a couple, it&#8217;s all good, but with feature laden themes, remembering each one becomes a chore. To rectify this, we&#8217;re going to add buttons directly to the TinyMCE interface, so the user can simply click on the button to get it all done. </p>
<p>As an example, I&#8217;m going to teach you how to add the second variation to the editor. I&#8217;m hoping you can extrapolate this information for the specific functionality you have in mind.</p>
<hr />
<h2><span>Step 1: </span>Hook into WordPress</h2>
<p>The first step in the process is hooking into WordPress and adding our initialization code. The following snippet takes care of that. Remember, all of this needs to be in your <code>functions.php</code> file.</p>
<pre name="code" class="php">
 add_action('init', 'add_button');
</pre>
<p>We&#8217;re asking WordPress to run the function called <code>add_button</code> when the page is initially loaded. <code>add_action</code> is our hook into WordPress&#8217; internals.</p>
<hr />
<h2><span>Step 2: </span>Create Our Initialization Function</h2>
<pre name="code" class="php">
function add_button() {
   if ( current_user_can('edit_posts') &#038;&#038;  current_user_can('edit_pages') )
   {
     add_filter('mce_external_plugins', 'add_plugin');
     add_filter('mce_buttons', 'register_button');
   }
}</pre>
<p>This tiny snippet of code will be executed when the page loads. Above, we&#8217;re checking whether the user has the necessary authorization to edit a page or a post before proceeding.</p>
<p>Once that&#8217;s done, we hook up two of our [to be written] functions to specific filters. Both of these actually hook into TinyMCE&#8217;s front end architecture through WordPress. The first is executed when the editor loads the plugins while the second is run when the buttons are about to be loaded.</p>
<p>In the example above, we proceed regardless of which mode the editor is in. If you want to display it only when the editor is in, say, visual mode, you&#8217;ll need to perform a quick check. If <code>get_user_option('rich_editing')</code> evaluates to <code>true</code>, you&#8217;re in visual mode. Otherwise, HTML mode. I typically tend to add these buttons only under visual mode but feel free to mix and match here. </p>
<hr />
<h2><span>Step 3: </span>Register Our Button</h2>
<pre name="code" class="php">
function register_button($buttons) {
   array_push($buttons, "quote");
   return $buttons;
}
</pre>
<p>The function merely adds our shortcode to the array of buttons. You can also add a divider between your new button and the previous buttons by passing in a | before.</p>
<hr />
<h2><span>Step 4: </span>Register Our TinyMCE Plugin</h2>
<pre name="code" class="php">
function add_plugin($plugin_array) {
   $plugin_array['quote'] = get_bloginfo('template_url').'/js/customcodes.js';
   return $plugin_array;
}
</pre>
<p>The snippet above lets TinyMCE, and WordPress, know how to handle this button. Here, we map our <em>quote</em> shortcode to a specific JavaScript file. We use the <em>get_bloginfo </em>method to get the path to the current template. For the sake of organization, I&#8217;m keeping my tinyMCE plugin along with my other JS files. </p>
<hr />
<h2><span>Step 5: </span>Write the TinyMCE Plugin</h2>
<p>Now onto the final portion of our endeavour. Remember, the following code goes into a file called<code> customcodes.js </code>placed in the JS directory of your theme. If you thought it went into <code>functions.php </code>like all the code above, no cookie for you!</p>
<pre name="code" class="js">
(function() {
    tinymce.create('tinymce.plugins.quote', {
        init : function(ed, url) {
            ed.addButton('quote', {
                title : 'Add a Quote',
                image : url+'/image.png',
                onclick : function() {
                     ed.selection.setContent('[quote]' + ed.selection.getContent() + '[/quote]');

                }
            });
        },
        createControl : function(n, cm) {
            return null;
        },
    });
    tinymce.PluginManager.add('quote', tinymce.plugins.quote);
})();
</pre>
<p>Looks a little complex but I assure you, it&#8217;s anything but. Let&#8217;s break it down into smaller section to make it easier for us to parse.</p>
<p><strong>First</strong> order of the day is a quick closure to keep from polluting the global namespace. Inside, we call the <code>create</code> method to create a new plugin passing in the name and other assorted attributes. For the sake of brevity, I&#8217;m just going to call my plugin <em>quote</em>.</p>
<p>Once inside, we define the <code>init</code> function that&#8217;s executed upon initialization. <code>ed</code> points to the instance of the editor while <code>url</code> points to the URL of the plugin code.</p>
<p>Most of the attributes should be fairly self explanatory. Note that the image you pass in is relative to the parent folder of the JS file that holds the code. Here it&#8217;d be <em>theme directory/js</em>.</p>
<p><strong>Next</strong> up, we create the event handler for this button through the <code>onclick</code> function. The one-liner it contains essentially gets the selected text, if any, and wraps it with out shortcode. <code>setContent</code> and <code>getContent</code> are helper methods provided by tinyMCE to manipulate the selected text.</p>
<p><strong>Finally</strong>, in the last line, we add the freshly created plugin to tinyMCE&#8217;s plugin manager. Pay attention to the names you&#8217;re using in each step. It&#8217;s error prone if you&#8217;re not paying attention. And that&#8217;s about it! We&#8217;re done! Load up the editor and make sure your spiffy new button is working. </p>
<div class="tutorial_image">
	<img src="http://d2o0t5hpnwv4c1.cloudfront.net/883_wpShortcodes/preview.png" alt="Tutorial Image" />
</div>
<hr />
<h2>Conclusion</h2>
<p>And there you have it. We&#8217;ve successfully integrated shortcodes into a WordPress theme in a very user friendly manner. Hopefully you&#8217;ve found this tutorial to be of help. Feel free to reuse this code elsewhere in your projects and chime in within the comments if you need any assistance.</p>
<p>Questions? Nice things to say? Criticisms? Hit the comments section and leave me a comment. Happy coding and thank you so much for reading!</p>
]]></content:encoded>
			<wfw:commentRss>http://net.tutsplus.com/tutorials/wordpress/wordpress-shortcodes-the-right-way/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Create a FAQ Page with WordPress and Custom Post Types</title>
		<link>http://net.tutsplus.com/tutorials/wordpress/creating-an-interactive-faq-with-wordpress-and-jquery-ui/</link>
		<comments>http://net.tutsplus.com/tutorials/wordpress/creating-an-interactive-faq-with-wordpress-and-jquery-ui/#comments</comments>
		<pubDate>Fri, 03 Dec 2010 15:38:19 +0000</pubDate>
		<dc:creator>Sumeet Chawla</dc:creator>
				<category><![CDATA[Custom WordPress Posts]]></category>
		<category><![CDATA[FAQ]]></category>
		<category><![CDATA[jQuery ui]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://net.tutsplus.com/?p=14767</guid>
		<description><![CDATA[<a href="http://rss.buysellads.com/click.php?z=1260013&#38;k=d754f1e9ba63a736ba8ff5ece958f7dd&#38;a=14767&#38;c=1170601007" target="_blank"><img src="http://rss.buysellads.com/img.php?z=1260013&#38;k=d754f1e9ba63a736ba8ff5ece958f7dd&#38;a=14767&#38;c=1170601007" border="0" alt="" /></a>In the web world, a FAQ page is created specifically for the viewers/customers, and contains general questions and their respective answers about a particular product or service. This tutorial details the process of creating a dedicated FAQ section in the WordPress backend with custom post types, as well as how to spice up the actual [...]]]></description>
			<content:encoded><![CDATA[<a href='http://rss.buysellads.com/click.php?z=1260013&k=d754f1e9ba63a736ba8ff5ece958f7dd&a=14767&c=1738574885' ><img src='http://rss.buysellads.com/img.php?z=1260013&k=d754f1e9ba63a736ba8ff5ece958f7dd&a=14767&c=1738574885' border='0' alt='' /></a><p>In the web world, a FAQ page is created specifically for the viewers/customers, and contains general questions and their respective answers about a particular product or service. This tutorial details the process of creating a dedicated FAQ section in the WordPress backend with custom post types, as well as how to spice up the actual page a bit by using jQuery and CSS.</p>
<p><span id="more-14767"></span></p>
<p>To accomplish our goal, we require a dedicated custom FAQ WordPress post type. That way, we can use the title and the content of these posts to display the FAQs in an innovative and user-friendly way.</p>
<hr />
<h2><span>Step 1: </span> Installing WordPress</h2>
<p>To begin creating the FAQ page, we, of course, must first install <a href="http://wordpress.org">WordPress</a> on our localhost. Installing WordPress is a piece of cake; however, if you&#8217;re new to this, here is a <a href="http://codex.wordpress.org/Installing_WordPress" >guide</A> that details the process.</p>
<blockquote class="pullquote">
<p>The TwentyTen template is the default theme that ships with WordPress. </p>
</blockquote>
<p>Once WordPress is ready to go, we should next create our custom theme, which will implement the FAQ functionality. There are various methods of creating a custom theme. Some prefer to create a new blank white template, while others like to create child themes of the new TwentyTen template. I have been using the Starker&#8217;s theme, by <a href="http://elliotjaystocks.com/">Elliot Jay Stocks</a> for a long time now; we&#8217;ll use it to create the new theme for our FAQ system. </p>
<p><A href="http://starkerstheme.com/">Download</A> the latest version of the Starker&#8217;s blank theme, and move the folder into &#8216;wp-content/themes&#8217;, located within the WordPress installation folder. Also, be sure to rename it to FAQ. Next, login to the backend administration panel of WordPress, click on &#8216;appearance/themes.&#8217; You will find that the default &#8216;TwentyTen&#8217; theme is activated, while the new theme, &#8216;Starkers,&#8217; is listed below it. Activate the Starkers theme.</p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/804_WordPressFAQ/activate-the-theme.jpg" alt="activate starkers theme"/></div>
<p>Upon activation, preview the site to verify that everything is, indeed, working properly. If all went according to plan, the site should look somewhat like the following image:</p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/804_WordPressFAQ/empty-theme.jpg" alt="blank starkers theme"/></div>
<hr/>
<h2><span>Step 2: </span> Implementing the FAQ Custom Post</h2>
<p>To implement the FAQ system, we are going to create a custom post type solely for this purpose. This will enable us to manage all the FAQs in one place, especially if the FAQ question base increases with time.</p>
<p>To implement a custom post, edit the <code>functions.php</code> file located in the FAQ theme folder. It will contain a good bit of code, so don&#8217;t be scared or confused. Scroll down to the bottom and append the following to add a new custom post. We begin by creating hooking a custom function to the initialization (<code>init</code>) action.</p>
<pre name="code" class="php">
// ADDING CUSTOM POST TYPE FAQ
add_action('init', 'my_custom_init');
</pre>
<p>This custom function will contain all the metadata for the custom post, and will also register the custom post within the WordPress database. Now, within the function, we are first going to define the labels which will be used in the backend administration panels. By labels, I mean the text that is going to show up in the user interface for adding, editing, and searching the FAQs in the admin panel.</p>
<pre name="code" class="php">
	 $labels = array(
	    'name' =&gt; _x('FAQs', 'post type general name'),
	    'singular_name' =&gt; _x('FAQ', 'post type singular name'),
	    'add_new' =&gt; _x('Add New', 'FAQ'),
	    'add_new_item' =&gt; __('Add New FAQ'),
	    'edit_item' =&gt; __('Edit FAQ'),
	    'new_item' =&gt; __('New FAQ'),
	    'view_item' =&gt; __('View FAQ'),
	    'search_items' =&gt; __('Search FAQs'),
	    'not_found' =&gt;  __('No FAQs found'),
	    'not_found_in_trash' =&gt; __('No FAQs found in Trash'),
	    'parent_item_colon' =&gt; ''
	  );
</pre>
<p>After we&#8217;ve defined the labels, we next define the arguments <code>array</code> for the <code>register_post_type</code> method. These arguments contain all the important information which will define the components of our FAQ post. For example, will it have a tag box; an excerpt box? We pass the array of labels defined above as an argument, as well.</p>
<pre name="code" class="php">
	$args = array(
	    'labels' =&gt; $labels,
	    'public' =&gt; true,
	    'publicly_queryable' =&gt; true,
	    'show_ui' =&gt; true,
	    'query_var' =&gt; true,
	    'rewrite' =&gt; true,
	    'capability_type' =&gt; 'post',
	    'hierarchical' =&gt; false,
	    'menu_position' =&gt; 5,
	    'supports' =&gt; array('title','editor','thumbnail','custom-fields')
	  );
</pre>
<p>Now that the arguments are defined, we can register the custom post type using the <code>register_post_type</code> method. You can learn more about this method by referring to its <a href="http://codex.wordpress.org/Function_Reference/register_post_type" >documentation</a> in the WordPress Codex. </p>
<pre name="code" class="php">
function my_custom_init()
{
  $labels = array(
    'name' =&gt; _x('FAQs', 'post type general name'),
    'singular_name' =&gt; _x('FAQ', 'post type singular name'),
    'add_new' =&gt; _x('Add New', 'FAQ'),
    'add_new_item' =&gt; __('Add New FAQ'),
    'edit_item' =&gt; __('Edit FAQ'),
    'new_item' =&gt; __('New FAQ'),
    'view_item' =&gt; __('View FAQ'),
    'search_items' =&gt; __('Search FAQs'),
    'not_found' =&gt;  __('No FAQs found'),
    'not_found_in_trash' =&gt; __('No FAQs found in Trash'),
    'parent_item_colon' =&gt; ''
  );
  $args = array(
    'labels' =&gt; $labels,
    'public' =&gt; true,
    'publicly_queryable' =&gt; true,
    'show_ui' =&gt; true,
    'query_var' =&gt; true,
    'rewrite' =&gt; true,
    'capability_type' =&gt; 'post',
    'hierarchical' =&gt; false,
    'menu_position' =&gt; 5,
    'supports' =&gt; array('title','editor','thumbnail','custom-fields')
  );
  register_post_type('faq',$args);
}
</pre>
<p>Check the administration panel to determine if the FAQ type post has, in fact, been added successfully. Hopefully, you&#8217;ll see the FAQ tab in the sidebar.</p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/804_WordPressFAQ/custom-post-added.jpg" alt="Custom post added to dashboard"/></div>
<h3> Dummy FAQ Posts </h3>
<p>Now go ahead and add some demo FAQs, because we need some data for creating and testing the template. The title of each FAQ post should be the question, and the content will be the answer.</p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/804_WordPressFAQ/add-new-faqs.jpg" alt="Adding some demo posts"/></div>
<hr/>
<h2><span>Step 3: </span> Coding the Template</h2>
<p>So far, we&#8217;ve created FAQ custom posts, as well as inserted a set of sample data. Now, we&#8217;ll code the template to display the FAQs, accordingly. The main logic I have used for organizing the template is: use the FAQ&#8217;s unique ID to link the question to the answers. Hence, we have two parts in the template: the questions section, listing all the FAQ titles; and the answer section, which displays the content of each of the FAQs.</p>
<p>Find the <code>header.php</code> file, open it, delete the <code>div</code> with an <code>id</code> of &#8220;access&#8221; at the bottom, and also the paragraph which contains the description of the blog. Now add the following code.</p>
<pre name="code" class="html">
&lt;body &gt;
	&lt;div id="page-wrap"&gt;
	&lt;h1&gt;
		&lt;a href="" title="" rel="home"&gt;
	&lt;/h1&gt;
	&lt;?php
	/**
	 * The main template file.
	 *
	 * This is the most generic template file in a WordPress theme
	 * and one of the two required files for a theme (the other being style.css).
	 * It is used to display a page when nothing more specific matches a query.
	 * E.g., it puts together the home page when no home.php file exists.
	 * Learn more: http://codex.wordpress.org/Template_Hierarchy
	 *
	 * @package WordPress
	 * @subpackage Starkers
	 * @since Starkers 3.0
	 */
	 get_header(); ?&gt;

	&lt;?php
		query_posts('post_type=faq&amp;order=ASC')
	?&gt;
</pre>
<p>After we retrieve our FAQ post data, we must frame the architecture of how the questions will be displayed. We shall do it in the following manner. All the content is wrapped within a <code>div</code> with an <code>id</code> of &#8220;content.&#8221;</p>
<pre name="code" class="html">
&lt;div id="content">
    &lt;?php if (have_posts()) : ?>
        &lt;h3>FAQs&lt;/h3>
        &lt;div id="questions">
            &lt;ul>
                &lt;?php while (have_posts()) : the_post(); ?>
                &lt;li>&lt;a href="#answer&lt;?php the_id() ?>">&lt;?php the_title(); ?>&lt;/a>&lt;/li>
                &lt;?php endwhile; ?>
            &lt;/ul>
        &lt;/div>
    &lt;?php else : ?>
        &lt;h3>Not Found&lt;/h3>
        &lt;p>Sorry, No FAQs created yet.&lt;/p>
    &lt;?php endif; ?>
</pre>
<p>The most important part here is where we assign the hyperlink with a value of &#8216;#answer&#8217; and append the post&#8217;s <code>id</code> to it. We can use this to jump to the answers, when clicked.</p>
<p>After we&#8217;ve displayed all of the questions, we &#8220;rewind&#8221; our posts to return to the beginning.</p>
<pre name="code" class="html">
	&lt;?php rewind_posts(); ?>
</pre>
<p>Now we will structure how the answers are going to appear, just below the questions.</p>
<pre name="code" class="html">
&lt;?php if (have_posts()) : ?>
    &lt;div id="answers">
        &lt;ul>
            &lt;?php while (have_posts()) : the_post(); ?>
                &lt;li id="answer&lt;?php the_id(); ?>">
                    &lt;h4>&lt;?php the_title(); ?>&lt;/h4>
                    &lt;?php the_content(); ?>
                &lt;/li>
            &lt;?php endwhile; ?>
        &lt;/ul>
    &lt;/div>
    &lt;?php endif; ?>
    &lt;?php wp_reset_query(); ?>
&lt;/div>
&lt;?php get_footer(); ?>
</pre>
<p>You can see that we are going to list the content of each post in a list element. Each list element will have an <code>id</code> of &#8220;answers&#8221; with the post <code>ID</code> appended to it. This is important: when the question is clicked, the view jumps to the content of the respective post. If you&#8217;re working along, preview your site; you should see all the posts listed in the architecture described above.</p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/804_WordPressFAQ/listing-the-faqs.jpg" alt="FAQ displated without any styling"/></div>
<hr/>
<h2><span>Step 4: </span> Styling the Template</h2>
<p>Styling of the FAQ page depends entirely on your tastes; you can proceed in any manner you wish. If you&#8217;re a designer, feel free to skip <em>Step 4</em>. What I have personally implemented is a smooth and clean layout. When the user clicks on the question, the page smoothly scrolls down to the respective answer and highlights it by changing the colour and increasing the font size. To achieve this, we&#8217;ll start by styling the template with CSS. We can make use of CSS3 to add some shadows and transition effects, too. Add the following CSS to <code>styles.css</code>.</p>
<pre name="code" class="css">
body{
    background-color: #bcbcbc;
}
.clear {
    clear: both;
}
h1,h2,h3,h4,h5,h6{
    color:#424242;
    font-family:Georgia,Arial,Helvetica,sans-serif;
    text-shadow: #fff 1px 1px 0px;
}
h1 a{
    color:#424242;
    font-size:50px;
    position:relative;
    top:11px;
    font-weight: normal;
    z-index: 100;
}
h3{
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 20px;
}
h4{
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 10px;
}
a{
    color: #3299bb;
    text-decoration: none;
    -moz-transition: all 0.2s ease-in-out;
    -webkit-transition: all 0.2s ease-in-out;
    -o-transition: all 0.2s ease-in-out;
    transition: all 0.2s ease-in-out;
}
#page-wrap{
    width: 750px;
    position: relative;
    margin: 0px auto 20px auto;
    padding-top: 50px;
}
#content{
    background-color: #e9e9e9;
    padding: 64px 35px 22px;
    font-size: 14px;
    font-family: Arial, Helvetica, sans-serif;
    -webkit-box-shadow: rgba(0,0,0,1) 0px 0px 4px;
    -moz-box-shadow: rgba(0,0,0,1) 0px 0px 4px;
    box-shadow: rgba(0,0,0,1) 0px 0px 4px ;
}
#content p{
    text-align:justify;
    font-size: 12px;
    line-height: 18px;
    margin-bottom: 10px;
}
#questions{
    margin-bottom: 50px;
}
#questions li{
    margin-bottom: 20px;
    color: #3299bb;
    list-style-type: disc;
    list-style-position: inside;
}
#questions ul li a{
    font-weight: bold;
}
#questions ul li a:hover{
    color: #00befd;
}
#questions ul li a:active{
    color: #e78c03;
}
#answers ul li{
    margin-bottom: 30px;
    clear: both;
}
#footer{
    padding-top:5px;
    text-align:center;
}
#footer p{
    color: #424242;
}
#footer a{
    color: #424242;
    font-weight: bold;
}
</pre>
<p>After styling the page, we should style the current FAQ. Note that we&#8217;ve also added a &#8216;Top&#8217; button to the current FAQ. To create the button, we&#8217;ll use a handful of CSS3 properties. </p>
<pre name="code" class="css">
.current-faq{
    background-color: #424242;
    color: #e9e9e9;
    padding:30px 30px 23px;
}
.current-faq h4{
    color: #e9e9e9;
    font-weight: bold;
    font-size:22px;
    text-shadow: #000 1px 1px 0px;
}
.top-button {
    border-top: 1px solid #96d1f8;
    background: #2289a8;
    background: -webkit-gradient(linear, left top, left bottom, from(#3299bb), to(#2289a8));
    background: -moz-linear-gradient(top, #3299bb, #2289a8);
    padding: 4px 8px;
    -webkit-border-top-left-radius: 6px;
    -moz-border-radius-topleft: 6px;
    border-top-left-radius: 6px;
    -webkit-box-shadow: rgba(0,0,0,1) -1px -1px 0;
    -moz-box-shadow: rgba(0,0,0,1) -1px -1px 0;
    box-shadow: rgba(0,0,0,1) -1px -1px 0;
    text-shadow: rgba(0,0,0,.4) -1px -1px 0;
    color: #ffffff;
    font-size: 11px;
    font-family: Georgia, serif;
    text-decoration: none;
    vertical-align: middle;
    font-weight: bold;
    float: right;
    right:-30px;
    position: relative;
}
.top-button:hover {
    border-top-color: #0b93bd;
    background: #0b93bd;
    color: #ffffff;
}
.top-button:active {
    border-top-color: #e78c03;
    background: #e78c03;
}
</pre>
<p>Check if the &#8216;current&#8217; <code>class</code> is working properly by assigning the class to any of the list elements. The current FAQ should look like the following:</p>
<div class="tutorial_image"><img src="http://d2o0t5hpnwv4c1.cloudfront.net/804_WordPressFAQ/current-faq.jpg" alt="Current Class Styling"/></div>
<hr/>
<h2><span>Step 5: </span> Adding a Pinch of jQuery UI</h2>
<p>We&#8217;ll use jQuery UI to add some effects to the page. You can <a href="http://jqueryui.com">download jQuery UI here</a>. We only need limited use of the whole UI library, hence, downloading only the UI core components will suffice. We also need the jQuery scrollTo plug-in for achieving the smooth scrolling effect &#8212; though you could also easily code this functionality on your own. Nonetheless, to save time, you can download the plug-in <a href="http://flesler.blogspot.com/2007/10/jqueryscrollto.html">here</a>.</p>
<p>First, we reference jQuery, the jQuery UI Core files, and the scrollTo plug-in within the <code>header.php</code> file. You can do this by adding the following code just before the <code>wp_head()</code> method.</p>
<pre name="code" class="html">
&lt;?php wp_enqueue_script("jquery"); ?>&lt;!--VERY IMPORTANT-->

&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js" type="text/javascript">&lt;/script>

&lt;script src="&lt;?php bloginfo('template_url') ?>/js/jquery-ui-1.8.4.custom.min.js" type="text/javascript">&lt;/script>

&lt;script src="&lt;?php bloginfo('template_url') ?>/js/jquery.scrollTo.js" type="text/javascript">&lt;/script>

&lt;script src="&lt;?php bloginfo('template_url') ?>/js/main.js" type="text/javascript">&lt;/script>
</pre>
<blockquote>
<p>
The <code>wp_enqueue_script</code> statement is needed in order to load jQuery safely.
</p>
</blockquote>
<p>To enable our desired functionality, we fetch the value of the <code>href</code> attribute from the clicked element (i.e. the question). This value is the <code>id</code> of the list element which contains the answer. Then, we scroll to the list element, and apply the &#8216;current&#8217; <code>class</code>. jQuery UI will ensure that the class is implemented on the list element smoothly and dynamically.</p>
<pre name="code" class="javascript">
$(document).ready(function(){
	$("div#questions ul a").click(function(){
		var selected = $(this).attr('href');
		selected += '"'+selected+'"';
		/*--Removing the Current class and the top button from previous current FAQs---*/
		$('.top-button').remove();
		$('.current-faq').removeClass();
		$.scrollTo(selected, 400 ,function(){
			$(selected).addClass('current-faq', 400, function(){
				$(this).append('&lt;a href="#" class="top-button">TOP&lt;/a>');
			});
		});
		return false;
	});
</pre>
<p>As mentioned earlier, we also have a &#8216;Top&#8217; button which scrolls the page back to the top.</p>
<pre name="code" class="javascript">
$('.top-button').live('click',function(){
		$(this).remove();
		$('.current-faq').removeClass('current-faq',400,function(){
			$.scrollTo('0px', 800);
		});
		return false;
	})
});
</pre>
<hr/>
<h2><span>Step 6: </span> Conclusion</h2>
<p>What you&#8217;ve learned today is merely one way of implementing a FAQ page. WordPress provides the power of custom fields, which can be used to further improve the functionality of the FAQ system. When it comes to adding other features to our FAQ page, your own creativity is the only limit! Feel free to share your ideas in the comments!</p>
]]></content:encoded>
			<wfw:commentRss>http://net.tutsplus.com/tutorials/wordpress/creating-an-interactive-faq-with-wordpress-and-jquery-ui/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

