<?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>archGFX &#187; code</title>
	<atom:link href="http://archgfx.net/tag/code/feed" rel="self" type="application/rss+xml" />
	<link>http://archgfx.net</link>
	<description>Austin web designer - Adam Freetly</description>
	<lastBuildDate>Thu, 19 Apr 2012 18:01:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Adding Gravatars to Posts</title>
		<link>http://archgfx.net/blog/2008/geek/blogging/adding-gravatars-to-posts</link>
		<comments>http://archgfx.net/blog/2008/geek/blogging/adding-gravatars-to-posts#comments</comments>
		<pubDate>Wed, 06 Feb 2008 10:32:43 +0000</pubDate>
		<dc:creator>adam</dc:creator>
				<category><![CDATA[blogging]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[gravatars]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://archgfx.net/blog/2008/geek/blogging/adding-gravatars-to-posts</guid>
		<description><![CDATA[With the launch of the Blueprint site, and all the hubbub over the release of Prologue, there are now a couple of good examples of using gravatars for more than just comments. The prologue function is a little weighty to be copied to other themes, since it's built for wordpress.com, so i thought I'd share [...]]]></description>
			<content:encoded><![CDATA[<p>With the launch of the Blueprint site, and all the <a href="http://iammattthomas.com/journal/another-word-on-prologue">hubbub over the release of Prologue</a>, there are now a couple of good examples of using gravatars for more than just comments.  The prologue function is a little weighty to be copied to other themes, since it's built for wordpress.com, so i thought I'd share my simple method.  It's almost identical to the <a href="http://ma.tt/2007/10/gravatar-enabled/#comment-428947">method matt posted</a>,</p>
<pre>
<pre class="brush: php; title: ; notranslate">
&lt;?php $md5 = md5( strtolower(get_the_author_email()) );
$default = urlencode( get_bloginfo(template_directory) .'/icons/author.png' );
echo &quot;&lt;img alt='avatar' class='photo' title='photo' src='http://www.gravatar.com/avatar.php?gravatar_id=$md5&amp;size=50&amp;rating=X&amp;default=$default'  /&gt;&quot;;
?&gt;
</pre>
</pre>
<p>Note that this assumes your theme has an <code>author.png</code> inside an icon folder.  Change that line to reflect the location of your default icon, or use <a href="http://use.perl.org/images/pix.gif">a blank default</a>. If you're using <a href="http://plaintxt.org/themes/sandbox">Sandbox</a>, or any other <a href="http://lorelle.wordpress.com/2007/09/01/microformats-and-wordpress-themes/">hCard-enabled</a> wordpress theme, you can insert this inside <code>&lt;div class="vcard"&gt;</code>, for added microformat-y goodness.  Otherwise, you can put it anywhere you like.  I've also added the same code to the top of my <code>author.php</code> file, inside <code>&lt;div class="archive-meta"&gt;</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://archgfx.net/blog/2008/geek/blogging/adding-gravatars-to-posts/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Adding Search results to WordPress 404 pages</title>
		<link>http://archgfx.net/blog/2007/geek/blogging/adding-search-results-to-wordpress-404-pages</link>
		<comments>http://archgfx.net/blog/2007/geek/blogging/adding-search-results-to-wordpress-404-pages#comments</comments>
		<pubDate>Wed, 12 Sep 2007 16:56:26 +0000</pubDate>
		<dc:creator>adam</dc:creator>
				<category><![CDATA[blogging]]></category>
		<category><![CDATA[404]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[query_posts]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[usability]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://archgfx.net/blog/2007/geek/blogging/adding-search-results-to-wordpress-404-pages</guid>
		<description><![CDATA[Okay, so all this redirection business, and the 404 logs it generates, made me really get annoyed with seeing the blank 404 page I have. It's just the basic page that comes with Sandbox. Looking at the page was especially frustrating, since I knew that the URL I was looking at was close to the [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, so all this redirection business, and the 404 logs it generates, made me really get annoyed with seeing the blank 404 page I have.  It's just the basic page that comes with <a href="http://sndbx.org">Sandbox</a>.  Looking at the page was especially frustrating, since I knew that the <acronym title='Uniform Resource Locator'><span class='caps'>URL</span></acronym> I was looking at was close to the name of the page I was looking for.  Inspired by <a href="http://www.smashingmagazine.com/2007/07/25/wanted-your-404-error-pages/">Smashing Magazine's 404 usability post</a>, I set off to figure it out.</p>
<p>I started with the <a href="http://weblogtoolscollection.com/archives/2004/08/05/404-search-function-for-wordpress/">404 Search from Weblog Tools Collection</a>, which simply redirects 404 pages to search results.  That's not technically correct behaviour, so I borrowed the first few lines of my <code>404.php</code> from their example:</p>
<p><code>
<pre class="brush: php; title: ; notranslate">
&lt;?php
$search_term = substr($_SERVER['REQUEST_URI'],1);
$search_term = urldecode(stripslashes($search_term));
$find = array (&quot;'.html'&quot;, &quot;'.+/'&quot;, &quot;'[-/_]'&quot;) ;
$replace = &quot; &quot; ;
$search_term = trim(preg_replace ( $find , $replace , $search_term ));
$search_term_q = preg_replace('/ /', '%20', $search_term);
get_header() ?&gt;
</pre>
<p></code></p>
<p>Then the rest of the 404 template, which you can  <a href="http://archgfx.net/blog/index.php/2006/history/1011001">check out here</a>, follows normally from <a href="http://sandbox-theme.googlecode.com/svn/trunk/404.php">the sandbox file</a>, until after the search field (which is important for usability).   I don't use this in my index or single page templates, because <a href="http://wpbits.wordpress.com/2007/08/21/making-wordpress-themes-ii-the-loop/#comment-618">404's shouldn't land there</a> (if they do, it's a problem with wp_query() ).  After the search field, we jump into a custom loop:</p>
<p><span id="more-1200"></span></p>
<p><code>
<pre class="brush: php; title: ; notranslate">
&lt;?php /* run the url as a query */
query_posts('s='. $search_term_q );
?&gt;
&lt;?php if ( have_posts() ) :
/* check to see if there are posts, before telling people something that isn't true */ ?&gt;
&lt;div class=&quot;content-column left&quot;&gt;&lt;h3&gt;You might have been looking for these posts&lt;/h3&gt;
&lt;ul&gt;
&lt;?php /* start the loop */
while ( have_posts() ) : the_post(); ?&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&quot;&lt;?php the_permalink() ?&gt;&quot; title=&quot;&lt;?php printf(__('Permalink to %s', 'sandbox'), wp_specialchars(get_the_title(), 1)) ?&gt;&quot; rel=&quot;bookmark&quot;&gt;&lt;?php the_title() ?&gt;&lt;/a&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;abbr title=&quot;&lt;?php the_time('Y-m-d\TH:i:sO'); ?&gt;&quot;&gt;&lt;?php unset($previousday); printf(__('%1$s', 'sandbox'), the_date('', '', '', false), get_the_time()) ?&gt;&lt;/abbr&gt;&lt;br /&gt;
&lt;em&gt;
&lt;?php printf(__('Posted in %s', 'sandbox'), get_the_category_list(', ')) ?&gt;
. &amp;nbsp;
&lt;?php comments_popup_link(__('Comments (0)', 'sandbox'), __('Comments (1)', 'sandbox'), __('Comments (%)', 'sandbox')) ?&gt;
&lt;/em&gt;
&lt;/li&gt;
&lt;?php /* end the loop */
endwhile; ?&gt;
&lt;/ul&gt;&lt;/div&gt;
&lt;?php /* close the list before closing the ifelse */
else : endif; ?&gt;
</pre>
<p></code></p>
<p>You can read the comments, but basically, we take the <acronym title='Uniform Resource Locator'><span class='caps'>URL</span></acronym> and use <code>query_posts() </code>to run it as a search, and return the results as a list, if there are any.  So far, it works for posts that I've referenced elsewhere, but it's not returning the actual post itself.  That's probably because I use category slugs in my <acronym title='Uniform Resource Locator'><span class='caps'>URL</span></acronym>'s. and BTW, the fancy code highlighting in this post is courtesy of a <a href="http://wordpress.org/extend/plugins/syntaxhighlighter/">fancy new plugin</a>.</p>
<p><ins datetime="2007-09-12T22:36:46+00:00"><strong>UPDATE</strong>: Some additional code was used from <a href="http://www.arunrocks.com/blog/archives/2006/03/01/a-nearly-perfect-404-error-page-in-wordpress/">Arun's nearly perfect 404</a>.</ins></p>
]]></content:encoded>
			<wfw:commentRss>http://archgfx.net/blog/2007/geek/blogging/adding-search-results-to-wordpress-404-pages/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Upgrading</title>
		<link>http://archgfx.net/blog/2007/geek/blogging/upgrading</link>
		<comments>http://archgfx.net/blog/2007/geek/blogging/upgrading#comments</comments>
		<pubDate>Wed, 16 May 2007 13:48:25 +0000</pubDate>
		<dc:creator>adam</dc:creator>
				<category><![CDATA[blogging]]></category>
		<category><![CDATA[2.2]]></category>
		<category><![CDATA[atom]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[upgrade]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://archgfx.net/blog/2007/geek/blogging/upgrading</guid>
		<description><![CDATA[wordpress 2.2 is out. Easy upgrading is still a ways off. unless you're me, and you've moved to SVN. then it's just svn switch http://svn.automattic.com/wordpress/branches/2.2/ the latest undocumented features include atom API support. all that coding in app.php does little good if you don't reference it. going off of what my wordpress.com blog looks like, [...]]]></description>
			<content:encoded><![CDATA[<p>wordpress <a href="http://wordpress.org/development/2007/05/wordpress-22/">2.2 is out</a>.  <a href="http://wordpress.org/extend/ideas/topic.php?id=44&amp;page&amp;replies=40">Easy upgrading</a> is still a ways off. unless you're me, and you've moved to SVN.  then it's just <code>svn switch http://svn.automattic.com/wordpress/branches/2.2/</code> <img src='http://archgfx.net/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>the latest undocumented features include atom <acronym title='Application Interface'><span class='caps'>API</span></acronym> support.  all that coding in app.php does little good if you don't reference it.   going off of what my wordpress.com blog looks like, you should add this to the head of your blog:</p>
<p><code>&lt;link rel="introspection" type="application/atomserv+xml" title="Atom api" href="&lt;?php bloginfo('url') ?&gt;/wp-app.php" /&gt;</code></p>
<p>you can implement that <a href="http://archgfx.net/blog/2007/geek/blogging/for-the-obsessive-theme-switchers">as a plugin</a>, or in your theme.  i'd love to see <a href="http://wordpress.org/extend/ideas/topic.php?id=439&amp;page&amp;replies=4"><acronym title='eXtensible Markup Language'><span class='caps'>XML</span></acronym> support moved to the core</a>, but that might just be me.</p>
]]></content:encoded>
			<wfw:commentRss>http://archgfx.net/blog/2007/geek/blogging/upgrading/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>for the obsessive theme switchers</title>
		<link>http://archgfx.net/blog/2007/geek/blogging/for-the-obsessive-theme-switchers</link>
		<comments>http://archgfx.net/blog/2007/geek/blogging/for-the-obsessive-theme-switchers#comments</comments>
		<pubDate>Mon, 16 Apr 2007 01:33:12 +0000</pubDate>
		<dc:creator>adam</dc:creator>
				<category><![CDATA[blogging]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://archgfx.net/blog/2007/asides/for-the-obsessive-theme-switchers</guid>
		<description><![CDATA[I'm prepetually unsatisfied by themes. it's not the theme authors' fault, i'm just restless. alex king pointed to more advice: From Install to Pimped Out that sounds like the advice i found when i started using wordpress. but for anyone who does, or might, change themes, it's wrong. when you're talking about meta tags, or [...]]]></description>
			<content:encoded><![CDATA[<p> I'm prepetually unsatisfied by themes.  it's not the theme authors' fault, i'm just restless.  alex king pointed to more advice: <a href="http://www.search-this.com/2007/03/14/wordpress-from-install-to-pimped-out/#comment-872">From Install to Pimped Out</a> that sounds like the advice i found when i started using wordpress.  but for anyone who does, or might, change themes, it's wrong.</p>
<p>when you're talking about meta tags, or feedburner <acronym title='Rich Site Summary'><span class='caps'>RSS</span></acronym> feeds, or custom title tags, you're talking about things you don't want to break when you change themes.  and there's no reason for them to. this is how i do it:  i wrote a plugin.</p>
<p>Gasp! Shock! horror!<br />
not really.  if you can handle everything in the post above, you can handle this plugin.  here's how it starts:</p>
<p><code>&lt;?php<br />
/*<br />
Plugin Name: archGFX Functions<br />
Plugin URI: http://archgfx.net/<br />
Description: all the things that i hack into themes, now they have their own file<br />
Version: 1.0<br />
Author: SunBurntKamel<br />
Author URI: http://archgfx.net/<br />
*/</code></p>
<p>you need to have a name, the rest of it's optional.</p>
<p>so, all that fun stuff that you want to add to the head of your blog?  dump it into a function:</p>
<p><code>function archGFX_head() { ?&gt;<br />
&lt;META NAME="Description" CONTENT="archGFX is the brand name used by Adam Freetly. This portfolio represents personal and collaborative work." /&gt;<br />
&lt;meta name="keywords" content="adam freetly, architecture, blog, portfolio, design, rendering" /&gt;<br />
&lt;META NAME="geo.position" CONTENT="41.92;-87.70" /&gt;<br />
&lt;META name="geo.region" content="US-IL" /&gt;<br />
&lt;META name="geo.placename" content="chicago" /&gt;<br />
&lt;link rel="shortcut icon" href="http://www.archgfx.net/images/blogrdfbg.jpg" /&gt;<br />
&lt;link rel="alternate" type="application/rss+xml" title="<acronym title='Rich Site Summary'><span class='caps'>RSS</span></acronym> 2.0" href="http://feeds.feedburner.com/archGFX" /&gt;<br />
&lt;link rel="search" href="http://archgfx.net/opensearchdescription.xml" type="application/opensearchdescription+xml" title="archGFX" /&gt;<br />
&lt;script src="http://www.google-analytics.com/urchin.js" type="text/javascript"&gt;<br />
&lt;/script&gt;<br />
&lt;script type="text/javascript"&gt;<br />
_uacct = "UA-91088-3";<br />
urchinTracker();<br />
&lt;/script&gt;<br />
&lt;?php }</code></p>
<p>obviously i have a few more things than average.  google analytics scripts, geo tags, favicon, etc.  you can call the function whatever you want, just remember it.  now that we've got all our code, we need to insert it:</p>
<p><code>add_action('wp_head', 'archGFX_head');<br />
?&gt;</code></p>
<p>that's it, save the file, activate your 'plugin', and you're good to go.  naturally, i do a few more things with this.  i also handle my footer copyright notice the same way, with<br />
<code><br />
add_action('wp_footer', 'archGFX_foot');</code></p>
<p>i add the mybloglog widget to my dashboard with<br />
<code>add_action('activity_box_end', 'archGFX_MBL');</code></p>
<p>and, i don't have to worry about forgetting to add any of it next time i switch themes.  the only thing that i don't put in the plugin is my title tags.  you can only have one of those.  so while i could add mine with a plugin, i'd have to delete the theme's title manually.</p>
]]></content:encoded>
			<wfw:commentRss>http://archgfx.net/blog/2007/geek/blogging/for-the-obsessive-theme-switchers/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Defective Themes: Duplicate Content</title>
		<link>http://archgfx.net/blog/2007/geek/blogging/defective-themes-duplicate-content</link>
		<comments>http://archgfx.net/blog/2007/geek/blogging/defective-themes-duplicate-content#comments</comments>
		<pubDate>Wed, 14 Mar 2007 16:50:00 +0000</pubDate>
		<dc:creator>adam</dc:creator>
				<category><![CDATA[blogging]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[themes]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://archgfx.net/blog/2007/asides/defective-themes-duplicate-content</guid>
		<description><![CDATA[Talking to Rob about his nifty architecture blog search engine, I realized just how important things like the Duplicate Content Cure Plugin are. Not just for fear of being kicked out of google, but because it makes your search results real. By default, your monthly, category, tag, and author pages (if they exist) show up, [...]]]></description>
			<content:encoded><![CDATA[<p>Talking to <a href="http://no2self.net/">Rob</a> about his nifty <a href="http://no2self.net/blogsearch">architecture blog search engine</a>, I realized just how important things like the  <a href="http://www.seologs.com/wordpress-duplicate-content-cure/">Duplicate Content Cure Plugin</a> are.  Not just for fear of being kicked out of google, but because it makes your search results <em>real</em>.  By default, your monthly, category, tag, and author pages (if they exist) show up, and force your relevant blog posts 'below the fold'.  Worse still, old articles won't show up on category pages, despite being the reason a person landed on your blog.  That's exactly what happens with a search engine that searches only blogs, without using google's blogsearch:  pages and pages of archives, before you get to actual posts.</p>
<p>So, the plugin is nice, but you can also do it in themes,  just add:</p>
<pre>
 &lt;?php if ( is_category() || is_archive() || is_search() || is_author() ) { ?&gt;

    &lt;meta name="robots" content="noindex,follow"&gt;&lt;?php

} ?&gt;

&lt;?php if (function_exists('is_tag')) { if ( is_tag() ) { ?&gt;

    &lt;meta name="robots" content="noindex,follow"&gt;

&lt;?php } } ?&gt;</pre>
<p>to <code>header.php</code>.  The UTW stuff (is_tag()) is a little annoying, but other than that, it's boilerplate.</p>
]]></content:encoded>
			<wfw:commentRss>http://archgfx.net/blog/2007/geek/blogging/defective-themes-duplicate-content/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

