<?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>Digging into WordPress &#187; archives</title>
	<atom:link href="http://digwp.com/tag/archives/feed/" rel="self" type="application/rss+xml" />
	<link>http://digwp.com</link>
	<description>Take your WordPress skills to the next level.</description>
	<lastBuildDate>Thu, 09 Feb 2012 19:03:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Dynamic Archives</title>
		<link>http://digwp.com/2010/10/dynamic-archives/</link>
		<comments>http://digwp.com/2010/10/dynamic-archives/#comments</comments>
		<pubDate>Fri, 29 Oct 2010 17:29:59 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[archives]]></category>
		<category><![CDATA[dropdown]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=3063</guid>
		<description><![CDATA[Have you ever seen WordPress archives where you select something (usually a month/year) from a dropdown and it takes you to a page where you can view that? It&#8217;s fairly common. WordPress almost has built in functionality for it, since you can specifically tell the wp_get_archives() function that you want the values to be returned [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever seen WordPress archives where you select something (usually a month/year) from a dropdown and it takes you to a page where you can view that? It&#8217;s fairly common. WordPress almost has built in functionality for it, since you can specifically tell the wp_get_archives() function that you want the values to be returned as <code>&lt;option&gt;</code>s. We can kick it up a notch though, and make the results show dynamically on the same page as the dropdowns through some Ajaxy JavaScript. We&#8217;ll even allow for multiple dropdowns (include the category as well) and make sure it&#8217;s flexible for your own alterations.</p>
<p><a href="http://digwp.com/archives/" class="button">View Demo</a></p>
<p><span id="more-3063"></span></p>
<div class="image-wrap">
<img src="http://digwp.com/wp-content/uploads/archives.png" alt="" title="archives" width="590"  class="alignnone size-full wp-image-3069" />
</div>
<h3>Step 1) Building the Dropdowns</h3>
<p>The dropdowns are pretty easy to create. Here I&#8217;ll make a div wrapper for both of them, then include a dropdown for month/year, and for category:</p>
<pre><code>&lt;div id="archive-browser"&gt;
	&lt;div&gt;
		&lt;h4&gt;Month&lt;/h4&gt;
		&lt;select id="month-choice"&gt;
			&lt;option val="no-choice"&gt; &amp;mdash; &lt;/option&gt;
			&lt;?php wp_get_archives(array(
			
				'type'    =&gt; 'monthly',
				'format'  =&gt; 'option'
			
			)); ?&gt;
		&lt;/select&gt;
	&lt;/div&gt;
	&lt;div&gt;
		&lt;h4&gt;Category&lt;/h4&gt;
		&lt;?php 

			wp_dropdown_categories('show_option_none= -- ');
					
		?&gt; 
	&lt;/div&gt;
&lt;/div&gt;</code></pre>
<p>Note that the WordPress functions for the two dropdowns are a bit different. wp_get_archives requires you to bring your own select wrapper, which wp_dropdown_categories does not. For the former, you&#8217;ll also need to include your own &#8220;no-choice&#8221; option. I&#8217;m sure the WordPress gang has their reasons for this kind of thing, but I&#8217;d prefer to see it standardized over time. </p>
<h3>Step 2) Let&#8217;s get ourselves a getter.php</h3>
<p>We&#8217;re going to be dynamically grabbing our archives and plunking them on the screen. That means JavaScript, and as usual with me, that means jQuery. But jQuery can&#8217;t do a WordPress query all by itself. JavaScript is a client-side technology and database stuff is a server-side activity. So we&#8217;re going to need an intermediary. A URL that our JavaScript can call to return to us exactly what we need. That&#8217;s what I&#8217;m calling a getter.php file. </p>
<p>Since we&#8217;re working with WordPress here, a great way to do this is to create a template of what we need, then publish a page using that template. That gives us a nice URL we can hit. So in our active theme, I have greated a file called &#8220;archive-getter.php&#8221;, and this is that code:</p>
<pre><code>&lt;?php

    /*
        Template Name: Archives Getter
    */
    
    $year = htmlspecialchars(trim($_POST['digwp_y']));
    $month = htmlspecialchars(trim($_POST['digwp_m']));
    $cat = htmlspecialchars(trim($_POST['digwp_c']));
    
    $querystring = "year=$year&amp;monthnum=$month&amp;cat=$cat&amp;posts_per_page=-1";
    
    query_posts($querystring); 
    
?&gt;

&lt;?php if (($year == '') &amp;&amp; ($month == '') &amp;&amp; ($cat == '-1')) { ?&gt;

	&lt;table id="archives-table"&gt;&lt;tr&gt;&lt;td style='text-align: center; font-size: 15px; padding: 5px;'&gt;Please choose from above.&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
	
&lt;?php } else { ?&gt;

	&lt;table id="archives-table"&gt;
	    &lt;?php    
	        if (have_posts()) : while (have_posts()) : the_post(); ?&gt;
	            &lt;tr&gt;
	            	&lt;td&gt;&lt;img src="&lt;?php echo get_post_meta($post-&gt;ID, 'PostThumb', true); ?&gt;" alt="" style="width: 35px;" /&gt;&lt;/td&gt;
	            	&lt;td&gt;&lt;a href='&lt;?php the_permalink(); ?&gt;'&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/td&gt;
	            	&lt;td&gt;&lt;?php comments_popup_link(' ', '1 Comment', '% Comments'); ?&gt;&lt;/td&gt;
	            	&lt;td&gt;&lt;?php the_date('m/j/Y'); ?&gt;&lt;/td&gt;
	            &lt;/tr&gt;
	    &lt;?php 
	        endwhile; else:
	        
	        	echo "&lt;tr&gt;&lt;td style='text-align: center; font-size: 15px; padding: 5px;'&gt;Nothing found.&lt;/td&gt;&lt;/tr&gt;";
	        
	        endif; 
	    ?&gt;
	&lt;/table&gt;

&lt;?php } ?&gt;</code></pre>
<p>Let&#8217;s go through it top to bottom:</p>
<ol>
<li>Special comment to tell WordPress this is an Template file</li>
<li>Set variables from three POST parameters. Clean them up in the process</li>
<li>Create a $query string in the format WordPress likes them in</li>
<li>Run a query_posts from that query string</li>
<li>If none of the variables are set, return a message telling the user to please select values.</li>
<li>If at least one variable is set&#8230;</li>
<li>Run &#8220;The Loop&#8221;</li>
<li>Output a table of the results, containing the post image, content, date, comments, etc.</li>
<li>If nothing is found, tell the user so</li>
</ol>
<h3>Step 3) Watching for Dropdown Menu Changes</h3>
<p>We&#8217;re going to be using jQuery, so <a href="http://digwp.com/2009/06/including-jquery-in-wordpress-the-right-way/">make sure jQuery is loaded in your theme</a>. Then we&#8217;ll need a JavaScript file from which to work. So I&#8217;ve created a file called archives.js in the js folder of my theme. I similarly made a CSS file for styling this, and then conditionally load both of them in the header.php file:</p>
<pre><code>&lt;?php if (is_page_template("archives.php")) { ?&gt;
   &lt;link rel="stylesheet" href="&lt;?php bloginfo('template_url'); ?&gt;/css/archives.css" type="text/css" /&gt;
   &lt;script src="&lt;?php bloginfo('template_url'); ?&gt;/js/archives.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;?php } ?&gt;</code></pre>
<p>Now that we have a working JavaScript enviornment, we can watch those select dropdown menus we built for changes:</p>
<pre><code>jQuery(function() {
  jQuery("#archive-browser select").change(function() {
     // dynamically load the archives
  });
});</code></pre>
<h3>Step 4) Dynamically Load New Archives</h3>
<p>Using the great base we already have going here, let&#8217;s write out all the code we need to dynamically load in those archives. One thing we haven&#8217;t covered yet is, where on the page do we load in these said archives? We&#8217;ll need a target. We could append it with JavaScript, but what they hey, I just stuck it into the template itself instead:</p>
<div id="archive-wrapper">
<div id='archive-pot'></div>
</div>
<p>The <code>#archive-pot</code> is where we&#8217;ll load in new markup as we get it. The wrapper is there because that way we can dynamically adjust the height and do it really nice and smoothly.</p>
<p>Now here&#8217;s the complete JavaScript:</p>
<pre><code>jQuery(function() {

	jQuery("#archive-wrapper").height(jQuery("#archive-pot").height());

	jQuery("#archive-browser select").change(function() {
	
		jQuery("#archive-pot")
			.empty()
			.html("&lt;div style='text-align: center; padding: 30px;'&gt;&lt;img src='/wp-content/themes/DiggingIntoWordPress-2/images/ajax-loader.gif' /&gt;&lt;/div&gt;");
	
		var dateArray = jQuery("#month-choice").val().split("/");
		var y = dateArray[3];
		var m = dateArray[4];
		var c = jQuery("#cat").val();
		
		jQuery.ajax({
		
			url: "/archives-getter/",
			dataType: "html",
			type: "POST",
			data: ({
				"digwp_y": y,
				"digwp_m" : m,
				"digwp_c" : c
			}),
			success: function(data) {
				jQuery("#archive-pot").html(data);
				
				jQuery("#archive-wrapper").animate({
					height: jQuery("#archives-table tr").length * 50
				});
			
			}
			
		});
			
	});

});</code></pre>
<ol>
<li>Set height of wrapper to height of inside. Seems weird, but now that the wrapper has a static height and hidden overflow, it won&#8217;t blast open when new content is added, we can animate it&#8217;s heigh accordingly.</li>
<li>Watch for dropdown changes</li>
<li>When a change happens, empty out the current showing archives and add an Ajax spinner graphic</li>
<li>Figure out the year and date that we need by tinkering with the default WordPress values in the <code>&lt;option&gt;</code></li>
<li>Grab the selected category</li>
<li>Launch an Ajax request to our getter file, POSTING the values we just collected</li>
<li>Upon success, drop the markup into the #archive-pot</li>
<li>Animate the wrapper to the new height needed</li>
</ol>
<h3>Little Important Note</h3>
<p>Notice how the data that we POST is prefixed with &#8220;digwp_&#8221;? I had a little brainbender on this, while I was trying to POST data as like &#8220;m&#8221; and &#8220;month&#8221; and things like that. Apparently WordPress doesn&#8217;t like that. It can 404 an otherwise perfectly good URL for you when you pass it parameters (GET or POST) in that format. <a href="http://digwp.com/?m=2007&#038;y=3849&#038;cat=w34we">Check it out</a>. So anyway, using your own prefixed parameters will save you that headache.</p>
<h3>Taking it further</h3>
<p>This is by no means limited to what we have done here. All were are doing it passing a getter file parameters that we want built into a query string. We could make checkboxes so you could pick multiple categories. We could include authors. We could include tags. The sky is the limit really.</p>
<h3>Demo</h3>
<p>I just did it right on this site, so you can see <a href="http://digwp.com/archives/">our own archives</a>.</p>
<hr />
<p><small>© 2010 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2010/10/dynamic-archives/">Permalink</a> | <a href="http://digwp.com/2010/10/dynamic-archives/#comments">23 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2010/10/dynamic-archives/&title=Dynamic Archives">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/archives/" rel="tag">archives</a>, <a href="http://digwp.com/tag/dropdown/" rel="tag">dropdown</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2010/10/dynamic-archives/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Randomized Grid of Posts</title>
		<link>http://digwp.com/2010/08/randomized-grid-of-posts/</link>
		<comments>http://digwp.com/2010/08/randomized-grid-of-posts/#comments</comments>
		<pubDate>Mon, 16 Aug 2010 15:31:11 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[archives]]></category>
		<category><![CDATA[grid]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=2673</guid>
		<description><![CDATA[I&#8217;m all about tinkering with different ideas to display posts with WordPress. After all, it&#8217;s just a bunch of data at our fingertips! WordPress makes it easy to output whatever we need. Not long ago we experimented with making a Thumbnail Based Archives. Now let&#8217;s build a Randomized Grid Archives. 1. Create a page template, [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m all about tinkering with different ideas to display posts with WordPress. After all, it&#8217;s just a bunch of data at our fingertips! WordPress makes it easy to output whatever we need. Not long ago we experimented with making a <a href="http://digwp.com/2010/07/thumbnail-based-archives/">Thumbnail Based Archives</a>. Now let&#8217;s build a <a href="http://digwp.com/archives/grid/">Randomized Grid Archives</a>.</p>
<p><img src="http://digwp.com/wp-content/uploads/gridexample.jpg" alt="" title="gridexample" width="590" height="337" class="alignnone size-full wp-image-2668" /></p>
<p><span id="more-2673"></span></p>
<h3>1. Create a page template, publish a page</h3>
<p>We need a totally unique page template to work with. So create a new one. You know, just make a file like grid-archives.php in your theme and put this PHP comment at the top and then WordPress will recognize it. Then create a new page, pick this template, and publish it. The name and content absolutely don&#8217;t matter, just put something there so you can recognize/find it later.</p>
<pre><code>&lt;?php
/*
Template Name: Thumb Archives - Grid
*/
?&gt;</code></pre>
<h3>2. Loop it</h3>
<p>This is pretty much the entire page. We&#8217;ll link out to an external stylesheet for styling. Then we run a Loop for 25 posts (in our demo, we also remove our link style posts). Each post is an anchor tag, and within, the post title, the post image thumbnail, and the excerpt.</p>
<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;

&lt;head&gt;
	&lt;meta charset="UTF-8" /&gt;
	&lt;title&gt;Grid Archives | Digging Into WordPress&lt;/title&gt;
	&lt;link rel="stylesheet" type="text/css" media="all" href="&lt;?php bloginfo("template_url"); ?&gt;/css/gridarchives.css" /&gt;
&lt;/head&gt;

&lt;body&gt;
	&lt;div id="page-wrap"&gt;
		&lt;?php query_posts('posts_per_page=25&amp;cat=-52'); ?&gt;
		&lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt;
			&lt;a href="&lt;?php the_permalink(); ?&gt;" class="box col&lt;?php echo rand(2,4); ?&gt;"&gt;
				&lt;span class="title"&gt;&lt;?php the_title(); ?&gt;&lt;/span&gt;
				&lt;img src="&lt;?php echo get_post_meta($post-&gt;ID, 'PostThumb', true); ?&gt;" alt="" /&gt;
				&lt;span class="ex"&gt;&lt;?php the_excerpt(); ?&gt;&lt;/span&gt;
			&lt;/a&gt;
		&lt;?php endwhile; endif; ?&gt;
	&lt;/div&gt;
&lt;/body&gt;
	
&lt;/html&gt;</code></pre>
<h3>3. Masonize</h3>
<p>Notice in the HTML above we echo&#8217;d out a random number between 2 and 4 as part of a class name. The results classes will be: col-2, col-3, and col-4. These represent columns. So each link box is &#8220;randomized&#8221; based on this class name. Some post link boxes are 2 columns wide, others 3, others 4. Font sizing and thumbnail sizing also adjusts accordingly.</p>
<pre><code>.box { margin: 10px; float: left; }
.box:hover { outline: 2px solid white; }
.box:hover .title { background: none; }
.box:hover .ex { background: none; color: white; }
.box:hover img { opacity: 0.4; }

.col2 { width: 180px; }
.col3 { width: 280px; }
.col4 { width: 380px; }

.col2 img { max-width: 80px; float: right; margin: 0 0 2px 10px; }
.col3 img { max-width: 100px; float: left; margin: 0 10px 2px 0; }
.col4 img { max-width: 120px; float: right; margin: 0 0 2px 10px; }

.title { background: #237abe; color: white; display: block; padding: 10px; overflow: hidden; }
.col2 .title { font-size: 16px; }
.col3 .title { font-size: 18px; }
.col4 .title { font-size: 20px; }

.ex { background: white; color: #222; display: block; padding: 10px; }
.col2 .ex { font-size: 11px; }
.col3 .ex { font-size: 12px; }
.col4 .ex { font-size: 13px; }</code></pre>
<p>So each of those post link boxes is just floated to the left. That&#8217;s going to make a pretty ragged and nasty layout all by itself, because each box will be a different height depending on the length of the title and excerpt. No problem though, we&#8217;re going to rearrange the boxes using the <a href="http://desandro.com/resources/jquery-masonry/">jQuery Masonry plugin</a> by David DeSandro. We&#8217;ll just call jQuery, the plugin, and the write a quick script to call it. This can go pretty much anywhere on the page. Typically jQuery is run on DOM ready, but in this case we are waiting for the window&#8217;s load event, because we want to wait for the thumbnails to load before masonizing.</p>
<pre><code>&lt;script src='http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js'&gt;&lt;/script&gt;
&lt;script src='&lt;?php bloginfo("template_url"); ?&gt;/js/jquery.masonry.min.js'&gt;&lt;/script&gt;
&lt;script&gt;
 $(window).load(function() {
   $("#page-wrap").masonry({
      columnWidth: 100, 
      animate: true, 
      animationOptions: {
          duration: 300,
          queue: false
      }
  });
 });
&lt;/script&gt;</code></pre>
<h3>Enjoy!</h3>
<p><a href="http://digwp.com/archives/grid/">Here is ours.</a> Let us know if you play with this on your own site at all.</p>
<hr />
<p><small>© 2010 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2010/08/randomized-grid-of-posts/">Permalink</a> | <a href="http://digwp.com/2010/08/randomized-grid-of-posts/#comments">17 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2010/08/randomized-grid-of-posts/&title=Randomized Grid of Posts">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/archives/" rel="tag">archives</a>, <a href="http://digwp.com/tag/grid/" rel="tag">grid</a>, <a href="http://digwp.com/tag/jquery/" rel="tag">jquery</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2010/08/randomized-grid-of-posts/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Thumbnail Based Archives</title>
		<link>http://digwp.com/2010/07/thumbnail-based-archives/</link>
		<comments>http://digwp.com/2010/07/thumbnail-based-archives/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 13:36:44 +0000</pubDate>
		<dc:creator>Chris Coyier</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[archives]]></category>
		<category><![CDATA[loop]]></category>

		<guid isPermaLink="false">http://digwp.com/?p=2604</guid>
		<description><![CDATA[Here at Digging Into WordPress, we&#8217;ve attached thumbnail images to every single (non-link-style) post since day one. We started before WordPress 3.0 had the specific feature for thumbnails. We did it just by attaching a file path to the thumbnail image as a custom field. We clearly display each of those thumbnails in the design [...]]]></description>
			<content:encoded><![CDATA[<p>Here at Digging Into WordPress, we&#8217;ve attached thumbnail images to every single (non-link-style) post since day one. We started before WordPress 3.0 had the specific feature for thumbnails. We did it just by attaching a file path to the thumbnail image as a custom field. We clearly display each of those thumbnails in the design of the homepage and other various pages where it makes sense. </p>
<p>The biggest reason we decided to attach post thumbnails from the beginning was that it is just an interesting bit of data to have available for every single post. It means that we could do something like display random thumbnails in the sidebar, or display thumbnails next to search results. We don&#8217;t do either of those things in this current design, but it&#8217;s always a possibility and possibilities are awesome. </p>
<p>Another thing that is a cool thing to build with thumbnails is unique archive views. I&#8217;ve <a href="http://digwp.com/archives/horz/">built one</a> for us here on Digging Into WordPress and I have some ideas for several more. Check it out:</p>
<p><a href="http://digwp.com/archives/horz/"><img src="http://digwp.com/wp-content/uploads/horzarchives.png" alt="" title="horzarchives" width="590" height="253" class="alignright size-full wp-image-2611" /></a></p>
<p>Read on for the &#8220;how&#8221;&#8230;</p>
<p><span id="more-2604"></span></p>
<h3>1. Created a special page template</h3>
<p>This page will be totally unique, no standard header or footer, so I made a template just for it.</p>
<pre><code>&lt;?php
/*
  Template Name: Thumb Archives - Horz
*/
?&gt;</code></pre>
<h3>2. Creating a horizontal row of thumbs</h3>
<p>One of the best ways to create long horizontal row (that breaks the width of the browser window width) is to use a table with a single row of cells. This way we don&#8217;t have to manually set the width of anything, and also don&#8217;t have to worry about things wrapping as we would if the thumbnails were inline elements or floated. </p>
<p>So we&#8217;ll set up a loop querying for every single post on the site (that isn&#8217;t a link-post) and spit out a table cell for each. Within that table cell, there will be an anchor link pointing to the post which contains a title, the image, and an excerpt.</p>
<pre><code>&lt;table id="archives-table"&gt;
	&lt;tr&gt;
		&lt;?php query_posts('posts_per_page=-1&amp;cat=-52'); ?&gt;
		&lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt;
		&lt;td&gt;
			&lt;a href="&lt;?php the_permalink(); ?&gt;" class="article-block"&gt;
				&lt;span class="title"&gt;&lt;?php the_title(); ?&gt;&lt;/span&gt;
				&lt;img src="&lt;?php echo get_post_meta($post-&gt;ID, 'PostThumb', true); ?&gt;" alt="" /&gt;
				&lt;span class="ex"&gt;&lt;?php the_excerpt(); ?&gt;&lt;/span&gt;
			&lt;/a&gt;
		&lt;/td&gt;
		&lt;?php endwhile; endif; ?&gt;
	&lt;/tr&gt;
&lt;/table&gt;</code></pre>
<h3>3. Dependencies</h3>
<p>We&#8217;re going to need a unique CSS file to use for this. Since this template is completely one-off and we aren&#8217;t using the standard header, the &lt;head> element will be right in this template. We&#8217;ll link out to our own custom CSS file, load in jQuery, and load in some plugins that will facilitate the idea I&#8217;m trying to accomplish (<a href="http://www.2meter3.de/code/hoverFlow/">hoverflow</a> and <a href="http://brandonaaron.net/code/mousewheel/docs">mousewheel</a>), as well as finally our own custom JavaScript file.</p>
<pre><code>&lt;head&gt;
  &lt;meta charset="UTF-8" /&gt;
  &lt;title&gt;Thumbnail Archives | Digging Into WordPress&lt;/title&gt;
  &lt;link rel="stylesheet" type="text/css" media="all" href="&lt;?php bloginfo("template_url"); ?&gt;/css/archives-horz.css" /&gt;
  &lt;script src='http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js'&gt;&lt;/script&gt;
  &lt;script src='&lt;?php bloginfo("template_url"); ?&gt;/js/jquery.hoverflow.min.js'&gt;&lt;/script&gt;
  &lt;script src='&lt;?php bloginfo("template_url"); ?&gt;/js/jquery.mousewheel.min.js'&gt;&lt;/script&gt;
  &lt;script src='&lt;?php bloginfo("template_url"); ?&gt;/js/weirdarchives.js'&gt;&lt;/script&gt;
&lt;/head&gt;</code></pre>
<p>If this page was anything more than a one-off page, we should be enqueuing scripts and providing proper hooks in the header and such. I&#8217;ve specifically not done that here because this page is it&#8217;s own unique thing that I don&#8217;t want anything else intruding upon. </p>
<h3>4. Style</h3>
<p>The styling for page is very simple, just a repeating background image and resets. Notice on the page though that the titles and excerpts are hidden until the mouse hovers over the thumbnails. We&#8217;ll do the &#8220;hiding&#8221; by setting the opacity of the thumbnails down to zero in the CSS. We&#8217;ll also position them inset into the thumbnail a bit so they have a bit more dramatic &#8220;reveal&#8221; upon mouse hover, as they slide out and into place.</p>
<pre><code>.title { bottom: 50%; }
.ex { top: 50%; font: 11px Georgia, Serif; color: #555; }
.title, .ex { background: white; width: 130px; padding: 10px; display: block; overflow: hidden; position: absolute; opacity: 0; }
</code></pre>
<h3>5. Horizontal scrolling</h3>
<p>With the mousewheel plugin in place, we can force the window to scroll horizontally instead of vertically with mouse scrollwheels with this:</p>
<pre><code>$("body").mousewheel(function(event, delta) {
    this.scrollLeft -= (delta * 30);
    event.preventDefault();
});</code></pre>
<h3>6. Animation</h3>
<p>When a thumbnail is hovered over, the title and except will show themselves and slide down. To do that, I&#8217;m using jQuery&#8217;s hover function which accepts a function to run on mouseenter and a function to run on mouseleave. For the former, an animation begins which moves the position, height, and opacity. The latter, those values are returned to how they started.</p>
<pre><code>$blocks.hover(function(e) {
    var $el    = $(this),
        $title = $el.find(".title"),
        $ex    = $el.find(".ex");
    
    $title.hoverFlow(e.type, { bottom: "99%", opacity: 1, height: $title.data("origHeight") })
    $ex.hoverFlow(e.type, { top: "95.5%", opacity: 1, height: $ex.data("origHeight") });
    
}, function(e) {
    $(this)
        .find(".title").hoverFlow(e.type, { bottom: "50%", opacity: 0, height: 0 })
        .end()
        .find(".ex").hoverFlow(e.type, { top: "50%", opacity: 0, height: 0 });
});</code></pre>
<p>There is a bit more to the JavaScript (but not much), feel free to poke your way around to it from the demo page to see it all.</p>
<h3>7. More</h3>
<p>The point of all this was to create a unique archive browsing experience based around our thumbnails. This isn&#8217;t the only way to do it. In fact I have a few other ideas I&#8217;m going to work on in time. Are they super practical? Maybe not, but they are fun! </p>
<hr />
<p><small>© 2010 <a href="http://digwp.com">Digging into WordPress</a> | <a href="http://digwp.com/2010/07/thumbnail-based-archives/">Permalink</a> | <a href="http://digwp.com/2010/07/thumbnail-based-archives/#comments">15 comments</a> | Add to <a href="http://del.icio.us/post?url=http://digwp.com/2010/07/thumbnail-based-archives/&title=Thumbnail Based Archives">del.icio.us</a> | Post tags: <a href="http://digwp.com/tag/archives/" rel="tag">archives</a>, <a href="http://digwp.com/tag/loop/" rel="tag">loop</a><br/></small></p>]]></content:encoded>
			<wfw:commentRss>http://digwp.com/2010/07/thumbnail-based-archives/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
	</channel>
</rss>

