<?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>Randy Reyes : Web Developer</title>
	<atom:link href="http://www.randypreyes.info/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.randypreyes.info</link>
	<description>A website design and development diary.</description>
	<lastBuildDate>Sat, 08 Oct 2011 22:54:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>AHL Plumbing</title>
		<link>http://www.randypreyes.info/ahl-plumbing/</link>
		<comments>http://www.randypreyes.info/ahl-plumbing/#comments</comments>
		<pubDate>Sat, 08 Oct 2011 22:54:12 +0000</pubDate>
		<dc:creator>Randy</dc:creator>
				<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://www.randypreyes.info/?p=349</guid>
		<description><![CDATA[AHL Plumbing is a local plumbing contractor that needed a website revamp. I improved there previous template site by providing a graphically re-designed look and re-organized their content in an efficient and succinct format. Since it was a simple project &#8230; <a href="http://www.randypreyes.info/ahl-plumbing/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>AHL Plumbing is a local plumbing contractor that needed a website revamp.  I improved there previous template site by providing a graphically re-designed look and re-organized their content in an efficient and succinct format.  Since it was a simple project I hand coded everything.  I also provided for a contact form that sent HTML-formatted emails to the client.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.randypreyes.info/ahl-plumbing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress Tag List With Counts</title>
		<link>http://www.randypreyes.info/wordpress-tag-list-counts/</link>
		<comments>http://www.randypreyes.info/wordpress-tag-list-counts/#comments</comments>
		<pubDate>Sun, 28 Aug 2011 05:03:56 +0000</pubDate>
		<dc:creator>Randy</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[ALL]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.randypreyes.info/?p=276</guid>
		<description><![CDATA[In this tutorial, I walk through how to build a list of WordPress tags with their respective post counts included. <a href="http://www.randypreyes.info/wordpress-tag-list-counts/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h6>Introduction</h6>
<p><img class="saw-border" style="float: right;" src="http://www.randypreyes.info/wp-content/uploads/2011/08/wordpress_tags.png" alt="WordPress Tags" />If you&#8217;re wondering how to make a WordPress tag list with their respective counts when you&#8217;re <em>outside</em> of the loop, then you&#8217;ve come to the right place. I came upon this issue when I was building the sidebar navigation for this site. Generally speaking, I couldn&#8217;t find much information on the subject so I had to resort to my own solution. After scouring the WordPress codex for relevant and usable functions I was able to figure out a method that worked for me.</p>
<p>&nbsp;</p>
<h6>The Plan</h6>
<ol>
<li>Get all the tags WordPress has stored.</li>
<li>Associate the tags with their respective counts.</li>
<li>Sort the tags by alphabetical order.</li>
<li>Print out the list.</li>
</ol>
<p>&nbsp;</p>
<h6>Get all the tags WordPress has stored.</h6>
<p><img class="saw-border" style="float: right;" src="http://www.randypreyes.info/wp-content/uploads/2011/08/wordpress_database_taxonomy.png" alt="WordPress Database Taxonomy" />I couldn&#8217;t find any WordPress functions that returned <em>all</em> of the tags that WordPress stored so I had to find some way of extracting that information directly from the WordPress database. After a little snooping around my local PHPMyAdmin panel, along with some light reading on the subject of WordPress terms and taxonomy, I found out where all the tags were being stored.  If you take a look inside the <code>wp_term_taxonomy</code> table you&#8217;ll find a field called &#8220;taxonomy&#8221; where WordPress stores the names of the types of terms being stored. Of all the names stored, &#8220;post_tag&#8221; is obviously the one we want.</p>
<p>The wonderful thing about WordPress is that it makes querying the database much easier with its <code>$wpdb</code> class which is stored in a global variable. If you aren&#8217;t familiar with this class you should really check out the <a title="WordPress Codex, WPDB Class" href="http://codex.wordpress.org/Class_Reference/wpdb" target="_blank">documentation</a> when you get the chance. You&#8217;ll definitely find it a necessity if you should ever get around to programming your own plugins.  For our purposes, we&#8217;ll be requiring the class to help us extract information from the database.  Here is the our database query using the <code>$wpdb</code> class.</p>
<p><span class="php_com">// Get the tags</span><br />
<span class="php_con">global</span> <span class="php_var">$wpdb</span><span class="php_bla">;</span><br />
<span class="php_var">$query</span> <span class="php_fun">=</span> <span class="php_str">&#8220;SELECT * FROM wp_term_taxonomy WHERE taxonomy=&#8217;post_tag&#8217;;&#8221;</span><span class="php_bla">;</span><br />
<span class="php_var">$rows</span> <span class="php_fun">=</span> <span class="php_var">$wpdb</span><span class="php_fun">-&gt;</span><span class="php_bla">get_results</span><span class="php_fun">(</span><span class="php_var">$query</span><span class="php_fun">)</span><span class="php_bla">;</span></p>
<p>The first thing to remember to do is the globalize the <code>$wpdb</code> variable so that we can properly utilize it. Just to make things spaced out and clear we store our query string into the <code>$query</code> variable. Then we use the <code>get_results()</code> function found within the <code>$wpdb</code> class to perform our query. As you can see, the results are stored as an object into the <code>$rows</code> variable.  Again, if you&#8217;re curious to see what values are stored in that object check out the <a title="WordPress Codex, WPDB Class" href="http://codex.wordpress.org/Class_Reference/wpdb" target="_blank">documentation</a>.</p>
<p>&nbsp;</p>
<h6>Associate the tags with their respective counts.</h6>
<p>Now that we have a collection of <code>post_tag</code> information, we can now go through each one and extract a <code>term_id</code> which we&#8217;ll need in order to get the string value of the tag, the number of posts associated with the tag, and the tag&#8217;s permalink.  With the help of WordPress&#8217;s <code>get_term()</code> and <code>get_tag_link()</code> functions we&#8217;ll be able to this.  But before we get into a loop to iterate through our <code>$rows</code> object, we first have to create an array where we&#8217;ll store this information into a variable, which we&#8217;ll call <code>$tag_list</code>.</p>
<p><span class="php_com">// Associate tags with counts</span><br />
<span class="php_var">$tag_list</span> <span class="php_fun">= array()</span><span class="php_bla">;</span><br />
<span class="php_con">if</span><span class="php_fun">(</span><span class="php_var">$wpdb</span><span class="php_fun">-&gt;</span><span class="php_bla">num_rows</span><span class="php_fun">&gt;</span><span class="php_num">0</span><span class="php_fun">){</span><br />
<span class="tab1"> </span><span class="php_con">foreach</span><span class="php_fun">(</span><span class="php_var">$rows</span> <span class="php_con">as</span> <span class="php_var">$row</span><span class="php_fun">){</span><br />
<span class="tab2"> </span><span class="php_var">$term</span> <span class="php_fun">=</span> <span class="php_bla">get_term</span><span class="php_fun">((</span><span class="php_var">int</span><span class="php_fun">)</span><span class="php_var">$row</span><span class="php_fun">-&gt;</span><span class="php_bla">term_id,</span><span class="php_str">&#8216;post_tag&#8217;</span><span class="php_fun">)</span><span class="php_bla">;</span><br />
<span class="tab2"> </span><span class="php_fun">array_push(</span><span class="php_var">$tag_list</span><span class="php_bla">,</span><span class="php_con">array</span><span class="php_fun">(</span><br />
<span class="tab3"> </span><span class="php_str">&#8216;name&#8217;</span> <span class="php_fun">=&gt;</span> <span class="php_var">$term</span><span class="php_fun">-&gt;</span><span class="php_bla">name,</span><br />
<span class="tab3"> </span><span class="php_str">&#8216;count&#8217;</span> <span class="php_fun">=&gt;</span> <span class="php_var">$row</span><span class="php_fun">-&gt;</span><span class="php_bla">count,</span><br />
<span class="tab3"> </span><span class="php_str">&#8216;link&#8217;</span> <span class="php_fun">=&gt;</span> <span class="php_bla">get_tag_link</span><span class="php_fun">((</span><span class="php_var">int</span><span class="php_fun">)</span><span class="php_var">$row</span><span class="php_fun">-&gt;</span><span class="php_bla">term_id</span><span class="php_fun">)</span><br />
<span class="tab2"> </span><span class="php_fun">))</span><span class="php_bla">;</span><br />
<span class="tab1"> </span><span class="php_fun">}</span><br />
<span class="php_fun">}</span></p>
<p>The <code>get_term()</code> function takes two arguments: the <code>term_id</code> and taxonomy name.  The object that gets returned has a property called &#8220;name&#8221; which we use to get the string representation of the tag.  The number of posts associated with the tag can be found in the &#8220;count&#8221; property of each <code>$row</code> object.  Finally, to get the tag&#8217;s permalink we use the <code>get_tag_link()</code> function, which takes in a term <code>id</code> value.  We store all this information into an associative array which, in turn, gets added to the <code>$tag_list</code> array.</p>
<p>&nbsp;</p>
<h6>Sort the tags by alphabetical order.</h6>
<p>Now that we&#8217;ve neatly collected the required information about our tags, we need to sort the <code>$tag_list</code> array in alphabetical order.  To do so we first need to set up a comparative function that will sort our multi-dimensional array according to its children&#8217;s &#8220;name&#8221; element.  (Remember that we stored a &#8220;name&#8221;, &#8220;count&#8221;, and &#8220;link&#8221; element into each child array.)  Below is the comparative function we&#8217;ll be using, which should be placed into the <code>functions.php</code> file.</p>
<p><span class="php_com">// Comparative function &#8211; alphabetical</span><br />
<span class="php_fun">function</span> <span class="php_bla">compare_alphabetical</span><span class="php_fun">(</span><span class="php_var">$a</span><span class="php_bla">,</span><span class="php_var">$b</span><span class="php_fun">){</span><br />
<span class="tab1"> </span><span class="php_con">if</span><span class="php_fun">(</span><span class="php_var">$a</span><span class="php_fun">[</span><span class="php_str">"name"</span><span class="php_fun">]==</span><span class="php_var">$b</span><span class="php_fun">[</span><span class="php_str">"name"</span><span class="php_fun">]){</span><br />
<span class="tab2"> </span><span class="php_con">return</span> <span class="php_num">0</span><span class="php_bla">;</span><br />
<span class="tab1"> </span><span class="php_fun">}</span> <span class="php_con">else if</span><span class="php_fun">(</span><span class="php_var">$a</span><span class="php_fun">[</span><span class="php_str">"name"</span><span class="php_fun">]&gt;</span><span class="php_var">$b</span><span class="php_fun">[</span><span class="php_str">"name"</span><span class="php_fun">]){</span><br />
<span class="tab2"> </span><span class="php_con">return</span> <span class="php_num">1</span><span class="php_bla">;</span><br />
<span class="tab1"> </span><span class="php_fun">}</span> <span class="php_con">else</span> <span class="php_fun">{</span><br />
<span class="tab2"> </span><span class="php_con">return</span> <span class="php_num">-1</span><span class="php_bla">;</span><br />
<span class="tab1"> </span><span class="php_fun">}</span><br />
<span class="php_fun">}</span></p>
<p>I&#8217;m still not knowledgeable enough to know exactly how sorting functions work but by just looking at the code you can get a gist of what&#8217;s going on.  Notice that two arguments are being passed into the function, which represent two elements from the array we&#8217;re sorting.  Instead of comparing the value of the elements, which are arrays, we compare the value of their &#8220;name&#8221; element.  Depending on the conditions we return a -1, 0, or 1, which is a requirement of all sorting functions.  Note that by switching <code>$a</code> and <code>$b</code> around, we can reverse the result of the final sort.</p>
<p>Moving on, we can now properly sort our <code>$tag_list</code> array with the following code:</p>
<p><span class="php_com">// Sort by alphabetical order</span><br />
<span class="php_fun">usort(</span><span class="php_var">$tag_list</span><span class="php_bla">,</span><span class="php_str">&#8220;compare_alphabetical&#8221;</span><span class="php_fun">)</span><span class="php_bla">;</span></p>
<p>&nbsp;</p>
<h6>Print out the list.</h6>
<p>Once we&#8217;ve sorted our list of tags, we can finally write out our list in <code>HTML</code>.  The following is the complete version of our code.</p>
<p><code><br />
<span class="htm_tag">&lt;ul&gt;</span><br />
<span class="php_num">&lt;?php</span></p>
<p><span class="php_com">// Get the tags</span><br />
<span class="php_con">global</span> <span class="php_var">$wpdb</span><span class="php_bla">;</span><br />
<span class="php_var">$query</span> <span class="php_fun">=</span> <span class="php_str">"SELECT * FROM wp_term_taxonomy WHERE taxonomy='post_tag';"</span><span class="php_bla">;</span><br />
<span class="php_var">$rows</span> <span class="php_fun">=</span> <span class="php_var">$wpdb</span><span class="php_fun">-&gt;</span><span class="php_bla">get_results</span><span class="php_fun">(</span><span class="php_var">$query</span><span class="php_fun">)</span><span class="php_bla">;</span></p>
<p><span class="php_com">// Associate tags with counts</span><br />
<span class="php_var">$tag_list</span> <span class="php_fun">= array()</span><span class="php_bla">;</span><br />
<span class="php_con">if</span><span class="php_fun">(</span><span class="php_var">$wpdb</span><span class="php_fun">-&gt;</span><span class="php_bla">num_rows</span><span class="php_fun">&gt;</span><span class="php_num">0</span><span class="php_fun">){</span><br />
<span class="tab1"> </span><span class="php_con">foreach</span><span class="php_fun">(</span><span class="php_var">$rows</span> <span class="php_con">as</span> <span class="php_var">$row</span><span class="php_fun">){</span><br />
<span class="tab2"> </span><span class="php_var">$term</span> <span class="php_fun">=</span> <span class="php_bla">get_term</span><span class="php_fun">((</span><span class="php_var">int</span><span class="php_fun">)</span><span class="php_var">$row</span><span class="php_fun">-&gt;</span><span class="php_bla">term_id,</span><span class="php_str">'post_tag'</span><span class="php_fun">)</span><span class="php_bla">;</span><br />
<span class="tab2"> </span><span class="php_fun">array_push(</span><span class="php_var">$tag_list</span><span class="php_bla">,</span><span class="php_con">array</span><span class="php_fun">(</span><br />
<span class="tab3"> </span><span class="php_str">'name'</span> <span class="php_fun">=&gt;</span> <span class="php_var">$term</span><span class="php_fun">-&gt;</span><span class="php_bla">name,</span><br />
<span class="tab3"> </span><span class="php_str">'count'</span> <span class="php_fun">=&gt;</span> <span class="php_var">$row</span><span class="php_fun">-&gt;</span><span class="php_bla">count,</span><br />
<span class="tab3"> </span><span class="php_str">'link'</span> <span class="php_fun">=&gt;</span> <span class="php_bla">get_tag_link</span><span class="php_fun">((</span><span class="php_var">int</span><span class="php_fun">)</span><span class="php_var">$row</span><span class="php_fun">-&gt;</span><span class="php_bla">term_id</span><span class="php_fun">)</span><br />
<span class="tab2"> </span><span class="php_fun">))</span><span class="php_bla">;</span><br />
<span class="tab1"> </span><span class="php_fun">}</span></p>
<p><span class="tab1"> </span><span class="php_com">// Sort by alphabetical order</span><br />
<span class="tab1"> </span><span class="php_fun">usort(</span><span class="php_var">$tag_list</span><span class="php_bla">,</span><span class="php_str">"compare_alphabetical"</span><span class="php_fun">)</span><span class="php_bla">;</span></p>
<p><span class="tab1"> </span><span class="php_com">// Write the list</span><br />
<span class="tab1"> </span><span class="php_con">foreach</span><span class="php_fun">(</span><span class="php_var">$tag_list</span> </span><span class="php_con">as</span> <span class="php_var">$tag</span><span class="php_fun">){</span><span class="php_num">?&gt;</span><br />
<span class="tab2"> </span><span class="htm_tag">&lt;li&gt;</span><br />
<span class="tab3"> </span><span class="htm_anc">&lt;a href="</span><span class="php_num">&lt;?php</span> <span class="php_con">echo</span><span class="php_fun">(</span><span class="php_var">$tag</span><span class="php_fun">[</span><span class="php_str">'link'</span><span class="php_fun">])</span><span class="php_bla">;</span> <span class="php_num">?&gt;</span><span class="htm_str">"</span><span class="htm_anc">&gt;</span><span class="php_bla">;</span><br />
<span class="tab4"> </span><span class="php_num">&lt;?php</span> <span class="php_con">echo</span><span class="php_fun">(</span><span class="php_var">$tag</span><span class="php_fun">[</span><span class="php_str">'name'</span><span class="php_fun">])</span><span class="php_bla">;</span> <span class="php_num">?&gt;</span> <span class="htm_txt">(</span><span class="php_num">&lt;?php</span> <span class="php_con">echo</span><span class="php_fun">(</span><span class="php_var">$tag</span><span class="php_fun">[</span><span class="php_str">'count'</span><span class="php_fun">])</span><span class="php_bla">;</span> <span class="php_num">?&gt;</span><span class="htm_txt">)</span><br />
<span class="tab3"> </span><span class="htm_anc">&lt;/a&gt;</span><br />
<span class="tab2"> </span><span class="htm_tag">&lt;/li&gt;</span><br />
<span class="tab1"> </span><span class="php_num">&lt;?php</span> <span class="php_fun">}</span></p>
<p><span class="php_fun">}</span></p>
<p><span class="php_num">?&gt;</span></p>
<p><span class="htm_tag">&lt;/ul&gt;</span><br />
</code></p>
<p>We begin in <code>HTML</code> by opening an unordered list element.  Immediately after, we place the code we&#8217;ve been working on from the beginning.  You&#8217;ll notice the final piece of code we added is a loop that iterates through our neatly sorted <code>$tag_list</code> array.  Within each loop we add a list item element which holds an anchor link.  By accessing the <code>$tag</code> array we can furnish our <code>HTML</code> appropriately as needed.  We end by exiting <code>PHP</code> and closing up our unordered list.</p>
<p>&nbsp;</p>
<h6>Closing</h6>
<p>There you have it!  A WordPress tag list, with their post counts, created outside of the loop.  I suppose you could use the same principles to get a list of categories as well if you wanted to do something fancy with that information.  In any case, I hope that you found this tutorial helpful and informative.  As always, your questions or comments are always welcome below.  Until next post, happy tag-listing!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.randypreyes.info/wordpress-tag-list-counts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Build an HTML 5 Video Player Tutorial</title>
		<link>http://www.randypreyes.info/build-an-html-5-video-player-tutorial/</link>
		<comments>http://www.randypreyes.info/build-an-html-5-video-player-tutorial/#comments</comments>
		<pubDate>Tue, 23 Aug 2011 22:55:25 +0000</pubDate>
		<dc:creator>Randy</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[ALL]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://www.randypreyes.info/?p=196</guid>
		<description><![CDATA[In this post series I will be talking about how to implement HTML 5 video into your website and creating your own set of video controls to ensure that your design and functionality remain cohesive across multiple platforms.  Keep in mind that this will be an <em>ongoing</em> post that I'll be periodically returning to until all the goals have been completed. <a href="http://www.randypreyes.info/build-an-html-5-video-player-tutorial/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><img class="saw-border" src="http://www.randypreyes.info/wp-content/uploads/2011/08/html_5_video.jpg" alt="HTML 5 Video" style="float:right;" />
<div style="color:#922;font-family:"Palatino Linotype", "Book Antiqua", Palatino, serif;font-size:0.9em;font-style:italic;">This is a post-in-progress.  I&#8217;ll cross items off the list as I finish them.  <del datetime="2011-08-23T22:47:40+00:00">Introduction</del>, <del datetime="2011-08-23T22:47:40+00:00">the basic video player</del>, the advanced video player, building the simple controls, building the draggable controls.</div>
<p>&nbsp;</p>
<h6>Introduction</h6>
<p>So I am now officially on the HTML 5 band wagon.  After poring over some forums and articles on video integration with HTML 5, I couldn&#8217;t help but feel inspired to learn more about this new hope for web development.  Along my web travels I happened to stumble upon Mozilla&#8217;s HTML 5 demos, which I found <a href="https://demos.mozilla.org/en-US/" title="HTML 5 Demos at Mozilla" target="_blank">HERE</a>, and I was simply blown away.  It was pretty much like interacting with a Flash movie but without the Flash!</p>
<p>But enough with the &#8220;oohs&#8221; and &#8220;ahhs&#8221; about HTML 5.  Let&#8217;s get on to why we&#8217;re here in the first place, which is HTML 5 video.  While HTML 5 still has a long way to go before being completely supported and in wide use, there are still some features of the HTML 5 specification that are currently being implemented.  Video is one of these features that&#8217;s slowly creeping its way into today&#8217;s websites.  The truly wonderful trait of HTML 5 is its cross-platform compatibility, and more importantly, its compatibility with mobile devices.  No longer will certain phones be kept out of the loop when it comes to watching videos on your website!</p>
<p>Though this new specification provides us with a way to distribute our videos to almost everyone with an internet connection, the fact of the matter is is that HTML 5 support is still taking its first baby steps.  Ultimately, this means that while we can still integrate video into our pages we still need to handle the situations where HTML 5 isn&#8217;t supported.  But fear not, in this tutorial we solve this problem and ensure that our content gets to the user, one way or another!</p>
<p>&nbsp;</p>
<h6>HTML 5 Video Player In Action</h6>
<p>Before we dive into the code here&#8217;s a preview of what this tutorial is all about.</p>
<div style="height:352px;position:relative;width:480px;"><div id="my_own_video_player" class="video_player" style="border:2px #000 solid;float:left;float:none;height:352px;margin:0px;padding:0px;position:relative;width:480px;"><div class="window"><video preload="none" width="480" height="352" poster="http://www.randypreyes.info/wp-content/uploads/2011/08/poster-html-5-video-test.jpg"><source src="http://www.randypreyes.info/wp-content/uploads/2011/08/html-5-video-test.mp4" type="video/mp4" /><source src="http://www.randypreyes.info/wp-content/uploads/2011/08/html-5-video-test.webm" type="video/webm" /><source src="http://www.randypreyes.info/wp-content/uploads/2011/08/html-5-video-test.ogv" type="video/ogg" /><object width="480" height="352"><param name="flashvars" value="src=http%3A%2F%2Fwww.randypreyes.info%2Fwp-content%2Fuploads%2F2011%2F08%2Fhtml-5-video-test.mp4&poster=http%3A%2F%2Fwww.randypreyes.info%2Fwp-content%2Fuploads%2F2011%2F08%2Fposter-html-5-video-test.jpg"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://fpdownload.adobe.com/strobe/FlashMediaPlayback.swf" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="352" flashvars="src=http%3A%2F%2Fwww.randypreyes.info%2Fwp-content%2Fuploads%2F2011%2F08%2Fhtml-5-video-test.mp4&poster=http%3A%2F%2Fwww.randypreyes.info%2Fwp-content%2Fuploads%2F2011%2F08%2Fposter-html-5-video-test.jpg"></embed></object></video><div class="controls"><div class="panel"><div class="play_toggle"><div class="pause">&nbsp;</div><div class="play">&nbsp;</div></div><div class="play_status_left">&nbsp;</div><div class="play_status"><div class="loaded">&nbsp;</div><div class="loaded_head">&nbsp;</div><div class="played">&nbsp;</div></div><div class="play_status_right">&nbsp;</div><div class="time"><p><span class="current_time">00:00</span>/<span class="duration">00:00</span></p></div><div class="head"><img class="head_graphic" src="http://www.randypreyes.info/wp-content/themes/randypreyes/images/video_player/head.png" /></div><div class="volume">&nbsp;</div><div class="screen_toggle"><div class="normal">&nbsp;</div><div class="full">&nbsp;</div></div></div><!-- end .panel --><div class="seek"><p><span class="seek_time">00:00</span></p></div><div class="volume_control"><div class="volume_level">&nbsp;</div><div class="volume_head"><img class="volume_head_graphic" src="http://www.randypreyes.info/wp-content/themes/randypreyes/images/video_player/volume_head.png" /></div><div class="substitute">&nbsp;</div></div></div><!-- end .controls --></div><!-- end .window --></div><!-- end .video_player --></div>
<p>&nbsp;<br />
You won&#8217;t know this until you&#8217;ve tested this out on other browsers, but there are actually three different source videos queued up to ensure that the content gets served no matter what browser or platform you&#8217;re using.  Granted, it won&#8217;t reach 100% of you, but it will certainly get pretty close.</p>
<p>You&#8217;ll also notice that the video player looks the same across all the browsers.  This is one of the nice perks of skinning your own media player.  Of course, if you don&#8217;t have the time to build a skin on your own you can always find some on the web.  <a href="http://videojs.com/" title="Videojs" target="_blank">Videojs</a>, for example, not only offer a couple of varieties of skins, but also features a convenient code builder that neatly creates video embed code for your own use.  If talk of pre-made skins haven&#8217;t veered you off this page yet, then read on to learn how you can make your own personal HTML 5 video player.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.randypreyes.info/build-an-html-5-video-player-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pagination for multi-page posts in WordPress</title>
		<link>http://www.randypreyes.info/pagination-for-multi-page-posts-in-wordpress/</link>
		<comments>http://www.randypreyes.info/pagination-for-multi-page-posts-in-wordpress/#comments</comments>
		<pubDate>Sat, 13 Aug 2011 11:35:10 +0000</pubDate>
		<dc:creator>Randy</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[ALL]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.randypreyes.info/?p=42</guid>
		<description><![CDATA[Ever wondered how to add pagination for multi-page posts in WordPress?  Or are you just curious about how pagination works?  Well, you've come to the right place.  In this tutorial I walk you through the steps of how I dealt with this problem. <a href="http://www.randypreyes.info/pagination-for-multi-page-posts-in-wordpress/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><img class="saw-border" style="float: right;" src="http://www.randypreyes.info/wp-content/uploads/2011/08/pagination_collage.png" alt="Pagination Collage" />For my new blog I had it in mind to do small tutorials on newly acquired skills as I learned them. As it turned out, the learning was rather instantaneous as I ran into the problem of paginating multi-page posts in WordPress. While WordPress does offer the <strong>wp_link_pages()</strong> function that automatically puts &#8220;Next&#8221; and &#8220;Previous&#8221; page links into a post, I was rather unhappy with how it looked and wanted something more customized. So I scoured the web for answers and was dismayed to see a lack of documentation about the subject. But being quite determined, I eventually settled upon a solution. And seeing as I came across this problem on my way to creating my first tutorial, it&#8217;s only fitting that this should be the subject of my first tutorial.</p>
<p>This first page will outline the basic concept of paginating a multi-page post in WordPress.  The second page will show you how to create &#8220;Previous&#8221; and &#8220;Next&#8221; links for your own customization purposes, as well as show you how to create the actual permalinks for the anchor tags.  So, without further ado, let&#8217;s discuss how to paginate a multi-page post in WordPress.</p>
<p>&nbsp;</p>
<h6>Assessing the situation</h6>
<p>Before plunging into anything I usually make a checklist of things that I would need to do in order to pull off whatever it is I&#8217;m trying to accomplish. After a few logical deductions I came up with the following list.</p>
<ol style="color: #83402e;">
<li>Check if the post is split up into pages.</li>
<li>Define the total amount of pages.</li>
<li>If we&#8217;re currently in a multi-page post, define what page we&#8217;re on.</li>
<li>Create links to the other pages.</li>
</ol>
<p>&nbsp;</p>
<h6>1 and 2 with one stone!</h6>
<p>In WordPress, the way we split posts up into pages is by inserting this code text where we want to split the page.</p>
<p><code>&lt;--nextpage--&gt;</code></p>
<p>So, in order to check if the current post has multiple pages, all we need to do is search through the post&#8217;s content for any instances of that code. Using the <strong>substr_count()</strong> function in PHP, we&#8217;ll be able to get the total number of occurrences of that code. If you&#8217;re inside the Loop, you could use the following code to accomplish this.</p>
<p><code><span class="php_var">$max_pages</span> <span class="php_fun">= substr_count(</span> <span class="php_var">$post-&gt;</span><span class="php_bla">post_content</span> , <span class="php_str">'&lt;!--nextpage--&gt;'</span> <span class="php_fun">) +</span> <span class="php_num">1</span><span class="php_bla">;</span></code></p>
<p>Note that we add 1 to the <strong>substr_count()</strong> result because every time we split the post we&#8217;re adding to the total number of pages we began with, which is 1. We store this value into a variable because we&#8217;ll be reusing this information later on.</p>
<p>&nbsp;</p>
<h6>What page are we on?</h6>
<p>To determine what the current page is we turn to the <strong>wp_query</strong> class which carries useful information regarding the requests we make to a WordPress blog. Among its numerous properties and methods is the <strong>query_vars</strong> array which holds the query variables and their values. Within this array resides the &#8220;page&#8221; variable if we should happen to be inside of a multi-page post or page. If it&#8217;s not set, we can clearly deduce we&#8217;re on the first page. Otherwise it would let us know if we&#8217;re on page two, or three, and so on.</p>
<p><code><span class="php_var">$page_num</span> <span class="php_fun">=</span> <span class="php_var">$wp_query-&gt;</span><span class="php_bla">query_vars</span><span class="php_fun">[ </span><span class="php_str">'page'</span><span class="php_fun"> ]</span><span class="php_bla">;</span><br />
<span class="php_con">if</span><span class="php_fun">( !</span><span class="php_var">$page_num</span> <span class="php_fun">) { </span><span class="php_var">$page_num</span> <span class="php_fun">=</span> <span class="php_num">1</span><span class="php_bla">; </span><span class="php_fun">}</span></code></p>
<p>The first line of code stores the value of &#8220;page&#8221; into a variable. Immediately afterward, we check to see if it&#8217;s actually set. If it&#8217;s not, then we set our page number variable to 1.</p>
<p>&nbsp;</p>
<h6>Create the page links.</h6>
<p>Now that we have the total number of pages and the current page number we can now make a list of page links. By using a &#8220;for&#8221; loop we&#8217;ll be able to iterate through all the page numbers from one to however many pages there are in the post. See the code below.</p>
<p><code><span class="php_con">for</span> <span class="php_fun">(</span> <span class="php_var">$i</span> <span class="php_fun">=</span> <span class="php_num">1</span> <span class="php_bla">;</span> <span class="php_var">$i</span> <span class="php_fun">&lt;</span> <span class="php_var">$max_pages</span> <span class="php_fun">+</span> <span class="php_num">1</span> <span class="php_bla">;</span> <span class="php_var">$i</span><span class="php_fun">++ ) {</span><br />
<span class="tab1"> </span><span class="php_con">echo</span> <span class="php_str">'&lt;a&gt;'</span>  <span class="php_var">. $i .</span> <span class="php_str">'&lt;/a&gt;'</span> <span class="php_bla">;</span><br />
<span class="php_fun">}</span></code></p>
<p>Voila! We have now provided a pagination scheme for a multi-page post in WordPress.</p>
<p>&nbsp;</p>
<h6>That&#8217;s it?!?!</h6>
<p>Well, that&#8217;s the basic gist of how we create pagination. The above example will do fine for most multi-page posts. I don&#8217;t imagine how anyone would need any heavy duty post pagination since it would be quite insane to break a single post into anything more than 20 or so pages. However, I could be wrong and there may be some good reasons to do so. And if I am, then that&#8217;ll be a topic for another tutorial!</p>
<p>For now, if you&#8217;re interested in something a bit more in depth, move on to the next page where we delve into constructing &#8220;Previous&#8221; and &#8220;Next&#8221; links.  And when you&#8217;re done with that we wrap things up with permalink creation and search engine optimization issues regarding multi-page posts.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.randypreyes.info/pagination-for-multi-page-posts-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Current Fix</title>
		<link>http://www.randypreyes.info/current-fix/</link>
		<comments>http://www.randypreyes.info/current-fix/#comments</comments>
		<pubDate>Wed, 10 Aug 2011 23:42:57 +0000</pubDate>
		<dc:creator>Randy</dc:creator>
				<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://currentfix.com/_projects/_randypreyes/?p=34</guid>
		<description><![CDATA[Current Fix is a poker blog that currently serves up to 50 people. In addition to serving as a game archive, the site is also updated on a weekly basis with articles and diary entries for the community&#8217;s consumption. The &#8230; <a href="http://www.randypreyes.info/current-fix/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Current Fix is a poker blog that currently serves up to 50 people.  In addition to serving as a game archive, the site is also updated on a weekly basis with articles and diary entries for the community&#8217;s consumption. The custom plugins created for the site help the administrator manage things like player stats, profile information, and game details.  Graphic-wise, it was build from the ground up and neatly fashioned with CSS.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.randypreyes.info/current-fix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Poker Chip Company</title>
		<link>http://www.randypreyes.info/poker-chip-company/</link>
		<comments>http://www.randypreyes.info/poker-chip-company/#comments</comments>
		<pubDate>Wed, 10 Aug 2011 23:29:34 +0000</pubDate>
		<dc:creator>Randy</dc:creator>
				<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://currentfix.com/_projects/_randypreyes/?p=32</guid>
		<description><![CDATA[The Poker Supply Company is a fictional entity designed to accommodate an exercise in WordPress theme customization and WordPress plugin development. Based on a real website, the project is an answer to how I would choose to revamp an outdated &#8230; <a href="http://www.randypreyes.info/poker-chip-company/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The Poker Supply Company is a fictional entity designed to accommodate an exercise in WordPress theme customization and WordPress plugin development.  Based on a real website, the project is an answer to how I would choose to revamp an outdated store front.  The site not only updates the old look, but also implements some new features that I thought the customer would find useful.  The custom chip widget is a prime example of this innovation.  Constructed in HTML and JavaScript, the widget allows the customer to preview products that the customer customizes using drop-down lists.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.randypreyes.info/poker-chip-company/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>No Me Digas!</title>
		<link>http://www.randypreyes.info/digas/</link>
		<comments>http://www.randypreyes.info/digas/#comments</comments>
		<pubDate>Wed, 10 Aug 2011 23:23:02 +0000</pubDate>
		<dc:creator>Randy</dc:creator>
				<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://currentfix.com/_projects/_randypreyes/?p=29</guid>
		<description><![CDATA[No Me Digas! is a bilingual online clothing store I put together in WordPress for a client. Using a commercial e-commerce theme, I customized its appearance to fit the client&#8217;s specific design needs. Two of the major required features were &#8230; <a href="http://www.randypreyes.info/digas/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>No Me Digas! is a bilingual online clothing store I put together in WordPress for a client.  Using a commercial e-commerce theme, I customized its appearance to fit the client&#8217;s specific design needs.  Two of the major required features were the animated splash page and the animated &#8220;About&#8221; page which were created using a combination of jQuery and Flash.  As of this moment the project is a work in progress.  However, the site is intended to go live within the month.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.randypreyes.info/digas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Heart For Home</title>
		<link>http://www.randypreyes.info/heart-home/</link>
		<comments>http://www.randypreyes.info/heart-home/#comments</comments>
		<pubDate>Wed, 10 Aug 2011 23:15:07 +0000</pubDate>
		<dc:creator>Randy</dc:creator>
				<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://www.randypreyes.info/?p=191</guid>
		<description><![CDATA[Heart For Home is a website for a non-profit organization dedicated to providing resources to underpriveledged children in the Philippines. It was a project started well before I got into WordPress so I actually built the site from the ground &#8230; <a href="http://www.randypreyes.info/heart-home/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Heart For Home is a website for a non-profit organization dedicated to providing resources to underpriveledged children in the Philippines.  It was a project started well before I got into WordPress so I actually built the site from the ground up which included a simple content management system.  While development has stalled for the time being, I do have plans on porting everything over to WordPress as that will certainly make online content management much easier for the client.  In addition, it will make e-commerce integration easier since accepting online payments is one of the primary goals of the website.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.randypreyes.info/heart-home/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Looks by Eileen</title>
		<link>http://www.randypreyes.info/eileen/</link>
		<comments>http://www.randypreyes.info/eileen/#comments</comments>
		<pubDate>Wed, 10 Aug 2011 23:10:49 +0000</pubDate>
		<dc:creator>Randy</dc:creator>
				<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://currentfix.com/_projects/_randypreyes/?p=26</guid>
		<description><![CDATA[Looks By Eileen is a simple 3-page portfolio site for a local cosmetology student. This particular version of the site was actually made from scratch without the ease of a content management system. To facilitate the client&#8217;s needs to make &#8230; <a href="http://www.randypreyes.info/eileen/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Looks By Eileen is a simple 3-page portfolio site for a local cosmetology student.  This particular version of the site was actually made from scratch without the ease of a content management system.  To facilitate the client&#8217;s needs to make simple updates, I built a very simplified content management system that permitted the client to manage photos and descriptions.  While the site does its job of displaying the client&#8217;s array of work, I have found it fit to update its design and functionality using WordPress.  Depending on the client&#8217;s wishes, you can expect a revamped version very soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.randypreyes.info/eileen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Flash Hole</title>
		<link>http://www.randypreyes.info/flash-hole/</link>
		<comments>http://www.randypreyes.info/flash-hole/#comments</comments>
		<pubDate>Wed, 10 Aug 2011 22:57:14 +0000</pubDate>
		<dc:creator>Randy</dc:creator>
				<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://currentfix.com/_projects/_randypreyes/?p=19</guid>
		<description><![CDATA[The Flash Hole was a proposed theme for my design and development blog. However, I ended up not using it. Instead I opted for the sharper look of the current theme being used now. But while I haven&#8217;t put the &#8230; <a href="http://www.randypreyes.info/flash-hole/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The Flash Hole was a proposed theme for my design and development blog. However, I ended up not using it.  Instead I opted for the sharper look of the current theme being used now. But while I haven&#8217;t put the theme into use, I serve it up here as an example of graphic design and WordPress experience.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.randypreyes.info/flash-hole/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- www.000webhost.com Analytics Code -->
<script type="text/javascript" src="http://analytics.hosting24.com/count.php"></script>
<noscript><a href="http://www.hosting24.com/"><img src="http://analytics.hosting24.com/count.php" alt="web hosting" /></a></noscript>
<!-- End Of Analytics Code -->

