<?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>Ardamis &#187; plugin</title>
	<atom:link href="http://www.ardamis.com/tag/plugin/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ardamis.com</link>
	<description>Ardamis is a blog about web development and technology in general.</description>
	<lastBuildDate>Thu, 02 Feb 2012 07:07:02 +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>Sitelinks are back on Ardamis</title>
		<link>http://www.ardamis.com/2010/10/17/sitelinks-are-back-on-ardamis/</link>
		<comments>http://www.ardamis.com/2010/10/17/sitelinks-are-back-on-ardamis/#comments</comments>
		<pubDate>Mon, 18 Oct 2010 04:33:48 +0000</pubDate>
		<dc:creator>ardamis</dc:creator>
				<category><![CDATA[Google]]></category>
		<category><![CDATA[Web Site Dev]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://www.ardamis.com/?p=1079</guid>
		<description><![CDATA[Ardamis.com once again has three Google sitelinks, as it did in mid-2009, and is approaching two million inbound links.]]></description>
			<content:encoded><![CDATA[<p>As of early October, Ardamis.com has its Google sitelinks back.  I first noticed them back in July of 2009, when <a href="http://www.ardamis.com/2009/07/01/toolbar-page-rank-of-6-and-3-one-line-sitelinks/">Ardamis had a toolbar PageRank of 6</a>.  Changes to Google&#8217;s algorithm later cost the site the sitelinks and reduced the PR to 5, which is how the site has appeared for the last year or so.  Three months ago, in July of 2010 and one year after the sitelinks appeared, I noticed that all of the pages combined had over <a href="http://www.ardamis.com/2010/07/13/one-million-inbound-links/">one million inbound links</a>.</p>
<p>This is what a <a href="http://www.google.com/search?q=ardamis">Google search for ardamis</a> returns:</p>
<div id="attachment_1080" class="wp-caption aligncenter" style="width: 510px"><a href="http://www.ardamis.com/wp-content/uploads/2010/10/ardamis-100310-sitelinks.png"><img src="http://www.ardamis.com/wp-content/uploads/2010/10/ardamis-100310-sitelinks.png" alt="Ardamis' Google sitelinks" title="ardamis-100310-sitelinks" width="500" height="414" class="size-full wp-image-1080" /></a><p class="wp-caption-text">Ardamis' Google sitelinks</p></div>
<p>The second result returned, <a href="http://www.ardamis.com/2010/03/12/final-fantasy-xiii-freezing-xbox-360/">Final Fantasy XIII freezing on Xbox 360</a>, is among my longest posts, has 91 comments, and enjoys some of the best inbound links of any page on the site, including from the <a href="http://forums.xbox.com/31685195/PrintPost.aspx">forums at Xbox.com</a>, <a href="http://kotaku.com/5494326/rumor-final-fantasy-xiii-ps3-has-freezing-issues">Kotaku</a> and <a href="http://www.gamesradar.com/ps3/final-fantasy-xiii/news/potentially-major-final-fantasy-xiii-freezing-issue-emerges/a-20100316104130477028/g-20060508175846527007">GamesRadar</a>.</p>
<p>The third result is my primary competition for the term <strong>ardamis</strong>, which briefly held the number one ranking a few months ago.   That site has some <a href="http://googlewebmastercentral.blogspot.com/2009/04/one-line-sitelinks.html">one-line site links</a>.</p>
<p>The actual mechanics of obtaining <a href="http://www.google.com/support/webmasters/bin/answer.py?hl=en&#038;answer=47334">sitelinks</a> remains a mystery, but there are plenty of people who are willing to speculate (and a few brave enough to promise they can deliver them for a price).</p>
<p>I&#8217;ve been posting more frequently, the site uses the <a href="http://wordpress.org/extend/plugins/wp-paginate/">WP-Paginate plugin</a> and according to <a href="http://www.google.com/webmasters/tools">Google&#8217;s Webmaster Tools</a>, the home page alone now has well over one million inbound links, but otherwise it&#8217;s been business as usual here.</p>
<div id="attachment_1081" class="wp-caption aligncenter" style="width: 511px"><a href="http://www.ardamis.com/wp-content/uploads/2010/10/ardamis-100310-inbound-links.png"><img src="http://www.ardamis.com/wp-content/uploads/2010/10/ardamis-100310-inbound-links.png" alt="Ardamis home page one million links" title="ardamis-100310-inbound-links" width="501" height="273" class="size-full wp-image-1081" /></a><p class="wp-caption-text">Over one million inbound links to the home page of Ardamis.com</p></div>
<p>I&#8217;m not going to speculate about how to get sitelinks or whether one or more of the changes in the last year was the catalyst, but Google does say to use descriptive and non-repetitive anchor and alt text in a site&#8217;s internal links and to keep important pages within a few clicks of the home page.  These are very basic, fundamental things that any site should do, but it bears repeating.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ardamis.com/2010/10/17/sitelinks-are-back-on-ardamis/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixing warnings in the WordPress Sociable plugin</title>
		<link>http://www.ardamis.com/2007/09/02/fixing-warnings-in-the-wordpress-sociable-plugin/</link>
		<comments>http://www.ardamis.com/2007/09/02/fixing-warnings-in-the-wordpress-sociable-plugin/#comments</comments>
		<pubDate>Sun, 02 Sep 2007 18:08:17 +0000</pubDate>
		<dc:creator>ardamis</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.ardamis.com/2007/09/02/fixing-warnings-in-the-wordpress-sociable-plugin/</guid>
		<description><![CDATA[This plugin is once again actively supported. Please download the latest version from http://wordpress.org/extend/plugins/sociable/. I&#8217;ve fixed some errors that I was experiencing with version 2.0 (dated 2007-02-02) of the Sociable WordPress plugin by Peter Harkins. Specifically, when running WordPress 2.2+, I would get the following warnings when saving changes: Warning: implode() [function.implode]: Bad arguments. in [...]]]></description>
			<content:encoded><![CDATA[<div class="success">This plugin is once again actively supported.  Please download the latest version from <a href="http://wordpress.org/extend/plugins/sociable/">http://wordpress.org/extend/plugins/sociable/</a>.
</div>
<p>I&#8217;ve fixed some errors that I was experiencing with version 2.0 (dated 2007-02-02) of the <a href="http://push.cx/sociable">Sociable</a> WordPress plugin by <a href="http://push.cx/">Peter Harkins</a>.  Specifically, when running WordPress 2.2+, I would get the following warnings when saving changes:</p>
<pre><code>Warning: implode() [function.implode]: Bad arguments. in PATH\wp-content\plugins\sociable\sociable.php on line 651

Warning: Invalid argument supplied for foreach() in PATH\wp-content\plugins\sociable\sociable.php on line 762
</code></pre>
<p>For each button, I&#8217;d get another error:</p>
<pre><code>Warning: in_array() [function.in-array]: Wrong datatype for second argument in PATH\wp-content\plugins\sociable\sociable.php on line 797
</code></pre>
<p>I think I&#8217;ve narrowed the cause down to the way the plugin was writing the newly selected options to the database.</p>
<p>In addition to fixing those warnings, I also corrected a few behaviors:</p>
<ol>
<li>The StumbleUpon button didn&#8217;t send the URL to the correct address at http://www.stumbleupon.com/.  The button now works correctly, and also sends the page&#8217;s title.</li>
<li>In Options -> Sociable, leaving the field for &#8220;text displayed in front of the icons&#8221; blank now results in no extraneous code being inserted into the page.  Leaving the field blank also eliminates the popup &#8220;These icons link to social bookmarking sites&#8230;&#8221; text.</li>
<li>The links to the social networking sites are now all <code>rel="nofollow"</code>.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.ardamis.com/2007/09/02/fixing-warnings-in-the-wordpress-sociable-plugin/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A plugin for adding the post date to wp_get_archives</title>
		<link>http://www.ardamis.com/2007/06/25/adding-the-post-date-to-wp_get_archives/</link>
		<comments>http://www.ardamis.com/2007/06/25/adding-the-post-date-to-wp_get_archives/#comments</comments>
		<pubDate>Mon, 25 Jun 2007 05:48:18 +0000</pubDate>
		<dc:creator>ardamis</dc:creator>
				<category><![CDATA[Web Site Dev]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[downloads]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://www.ardamis.com/2007/06/25/adding-the-post-date-to-wp_get_archives/</guid>
		<description><![CDATA[A plugin replacement for wp_get_archives that displays each post's date.]]></description>
			<content:encoded><![CDATA[<p>The WordPress function wp_get_archives(&#8216;type=postbypost&#8217;) displays a lovely list of posts, but won&#8217;t show the date of each post.  This plugin adds each post&#8217;s date to those &#8216;postbypost&#8217; lists, like so:</p>
<div id="attachment_892" class="wp-caption aligncenter" style="width: 367px"><a href="http://www.ardamis.com/wp-content/uploads/2007/06/wp_get_archives-replacement.png"><img src="http://www.ardamis.com/wp-content/uploads/2007/06/wp_get_archives-replacement.png" alt="Add dates to wp_get_archives" title="wp_get_archives-replacement" width="357" height="125" class="size-full wp-image-892" /></a><p class="wp-caption-text">Add dates to wp_get_archives</p></div>
<h2>Usage</h2>
<ol>
<li>Upload and activate the plugin</li>
<li>Edit your theme, replacing <code>wp_get_archives('type=postbypost')</code> with <code>if (function_exists('ard_get_archives')) ard_get_archives();</code></li>
</ol>
<p>The function <code>ard_get_archives();</code> replaces <code>wp_get_archives('type=postbypost')</code>, meaning you don&#8217;t need to specify <code>type=postbypost</code>.  You can use all of the wp_get_archives() parameters except &#8216;type&#8217; and &#8216;show_post_count&#8217; (limit, format, before, and after).  In addition, there&#8217;s a new parameter: <code>show_post_date</code>, that you can use to hide the date, but the plugin will show the date by default.</p>
<p><strong>show_post_date</strong><br />
<em>(boolean)</em> Display date of posts in an archive (1 &#8211; true) or do not (0 &#8211; false). For use with ard_get_archives(). Defaults to 1 (true).</p>
<h2>Customizing the date</h2>
<p>By default, the plugin displays the date as &#8220;(MM/DD/YYYY)&#8221;, but you can change this to use any standard <a href="http://www.php.net/date">PHP date characters</a> by editing the plugin at the line:</p>
<pre class="brush: php; title: ; notranslate">$arc_date = date('m/d/Y', strtotime($arcresult-&gt;post_date));  // new</pre>
<p>The date is wrapped in <code><span class="recentdate"></code> tags, so you can style the date independently of the link.</p>
<h2>How does it work?</h2>
<p>The plugin replaces the &#8216;postbypost&#8217; part of the function wp_get_archives, and adds the date to $before.  The relevant code is below.  You can compare it to the corresponding lines in general-template.php.</p>
<pre class="brush: php; title: ; notranslate">	} elseif ( ( 'postbypost' == $type ) || ('alpha' == $type) ) {
		('alpha' == $type) ? $orderby = &quot;post_title ASC &quot; : $orderby = &quot;post_date DESC &quot;;
		$arcresults = $wpdb-&gt;get_results(&quot;SELECT * FROM $wpdb-&gt;posts $join $where ORDER BY $orderby $limit&quot;);
		if ( $arcresults ) {
			$beforebefore = $before;  // new
			foreach ( $arcresults as $arcresult ) {
				if ( $arcresult-&gt;post_date != '0000-00-00 00:00:00' ) {
					$url  = get_permalink($arcresult);
					$arc_title = $arcresult-&gt;post_title;
					$arc_date = date('m/d/Y', strtotime($arcresult-&gt;post_date));  // new
					if ( $show_post_date )  // new
						$before = $beforebefore . '&lt;span class=&quot;recentdate&quot;&gt;' . $arc_date . '&lt;/span&gt;';  // new
					if ( $arc_title )
						$text = strip_tags(apply_filters('the_title', $arc_title));
					else
						$text = $arcresult-&gt;ID;
					echo get_archives_link($url, $text, $format, $before, $after);
				}
			}
		}
	}
</pre>
<p>The lines ending in &#8216;// new&#8217; are the only changes.</p>
<p>So you want the date to appear after the title?  Edit the plugin to modify $after, instead:</p>
<pre class="brush: php; title: ; notranslate">	} elseif ( ( 'postbypost' == $type ) || ('alpha' == $type) ) {
		('alpha' == $type) ? $orderby = &quot;post_title ASC &quot; : $orderby = &quot;post_date DESC &quot;;
		$arcresults = $wpdb-&gt;get_results(&quot;SELECT * FROM $wpdb-&gt;posts $join $where ORDER BY $orderby $limit&quot;);
		if ( $arcresults ) {
			$afterafter = $after;  // new
			foreach ( $arcresults as $arcresult ) {
				if ( $arcresult-&gt;post_date != '0000-00-00 00:00:00' ) {
					$url  = get_permalink($arcresult);
					$arc_title = $arcresult-&gt;post_title;
					$arc_date = date('j F Y', strtotime($arcresult-&gt;post_date));  // new
					if ( $show_post_date )  // new
						$after = '&amp;nbsp;(' . $arc_date . ')' . $afterafter;  // new
					if ( $arc_title )
						$text = strip_tags(apply_filters('the_title', $arc_title));
					else
						$text = $arcresult-&gt;ID;
					echo get_archives_link($url, $text, $format, $before, $after);
				}
			}
		}
	}
</pre>
<h2>Download</h2>
<p>Get the files here: (Current version: 0.1 beta)</p>
<p class="download"><a href="http://www.ardamis.com/downloads/ardamis-dateme.zip">Download the Ardamis DateMe WordPress Plugin</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ardamis.com/2007/06/25/adding-the-post-date-to-wp_get_archives/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>Halo 3 Service Record WordPress Plugin</title>
		<link>http://www.ardamis.com/2007/06/10/halo-3-service-record-wordpress-plugin/</link>
		<comments>http://www.ardamis.com/2007/06/10/halo-3-service-record-wordpress-plugin/#comments</comments>
		<pubDate>Sun, 10 Jun 2007 05:13:54 +0000</pubDate>
		<dc:creator>ardamis</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Web Site Dev]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://www.ardamis.com/2007/06/10/halo-3-service-record-wordpress-plugin/</guid>
		<description><![CDATA[This plugin allows you to add information from your Halo 3 Service Record to your WordPress blog.]]></description>
			<content:encoded><![CDATA[<div class="error"><strong>Update 7/31/10:</strong> I no longer support this plugin and have removed it from the site.  You can still download the code, if you like, but it needs to be updated before it will work correctly.
</div>
<p>This plugin allows you to add information from your Halo 3 Service Record to your WordPress blog.</p>
<p>The plugin displays your emblem, rank and grade, but with a little editing it could also display total the total number of games played, the date and time of the last game played, and any other information on the Halo 3 Service Record page at <a href="http://www.bungie.net/Stats/Halo3/Default.aspx?player=ardamis">Bungie.net</a>.</p>
<h3>Installation</h3>
<p>The download includes:</p>
<ul>
<li>ardamis-halo3.php (put this in your /plugins/ directory)</li>
<li>halo3stats.css (copy and paste the contents into your theme&#8217;s style.css)</li>
</ul>
<p>The plugin attempts to create a text file (halo3_cache_YOURTAG.txt) for use as a cache in your blog&#8217;s root folder automatically.  Some server configurations may not permit the plugin to create this file and you&#8217;ll see resultant errors; in this case, you may have to manually create a file with that name and upload it to your blog&#8217;s root (and perhaps set permissions).</p>
<h3>Usage</h3>
<p>The plugin accepts one argument: your gamertag.</p>
<p>Insert the code:</p>
<pre class="brush: php; title: ; notranslate">&lt;?php if (function_exists('ardamis_halo3')) ardamis_halo3('YOURTAG'); ?&gt;</pre>
<p>into a template file wherever you want the Service Record to appear, replacing YOURTAG with your actual Xbox Live gamertag, ex.:</p>
<pre class="brush: php; title: ; notranslate">&lt;?php if (function_exists('ardamis_halo3')) ardamis_halo3('ardamis'); ?&gt;</pre>
<h3>Download</h3>
<p>Get the files here: (Current version: 1.0 beta)</p>
<p class="download"><a href="http://www.ardamis.com/downloads/halo3-plugin.zip9">Download the Halo 3 WordPress Plugin</a></p>
<h2>How can I add the Service Record to a post?</h2>
<p>Thanks to a really neat plugin, <a href="http://www.navidazimi.com/projects/wp-exec">The Execution of All Things</a>, you can call functions from any activated plugin from within a post.  Once you have both the Halo 3 Service Record plugin and the wp-exec plugin installed, you can include the sig in a post with the line:</p>
<pre class="brush: php; title: ; notranslate">&lt;exec type=&quot;function&quot; name=&quot;ardamis_halo3&quot; params=&quot;YOURTAG&quot; /&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ardamis.com/2007/06/10/halo-3-service-record-wordpress-plugin/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Apricot &#8211; A Minimalist WordPress Theme</title>
		<link>http://www.ardamis.com/2007/06/03/apricot/</link>
		<comments>http://www.ardamis.com/2007/06/03/apricot/#comments</comments>
		<pubDate>Mon, 04 Jun 2007 04:44:28 +0000</pubDate>
		<dc:creator>ardamis</dc:creator>
				<category><![CDATA[Web Site Dev]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[downloads]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[templates]]></category>
		<category><![CDATA[themes]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://www.ardamis.com/2007/06/03/apricot/</guid>
		<description><![CDATA[Apricot is a text-centric, minimalist WordPress theme built on a Kubrick foundation.  It does SEO right, straight out of the box.]]></description>
			<content:encoded><![CDATA[<p>Apricot is a text-heavy and graphic-light, widget- and tag-supporting minimalist WordPress theme built on a Kubrick foundation.  Apricot validates as XHTML 1.0 Strict and uses valid CSS.  It natively supports the excellent <a href="http://www.dagondesign.com/articles/other-posts-from-cat-plugin-for-wordpress/">Other Posts From Cat</a> and <a href="http://guff.szub.net/plugins/">the_excerpt Reloaded</a> plugins, should you want to install them.</p>
<p>WordPress version 2.3 introduces native support for &#8216;tags&#8217;, a method of organizing posts according to key words.  Apricot has been updated to use this native tag system.  The tag cloud will appear in the sidebar and the tags for each post appear above the meta data.</p>
<p>I used Apricot on this site for over a year, making little tweaks and adjustments the whole time, so the theme is pretty thoroughly tested in a variety of different browsers and resolutions.  While the markup is derived from the WordPress default theme, Kubrick, I&#8217;ve added a few modifications of my own.  I&#8217;ve listed some of these changes below.</p>
<h3>header.php</h3>
<ul>
<li>Title tag reconfigured to display &#8220;Page Title | Site Name&#8221;</li>
</ul>
<h3>single.php</h3>
<ul>
<li>Post title is now wrapped in H1 tags</li>
<li>Metadata shows when the post was last modified (if ever)</li>
<li><span  style="text-decoration: line-through;">Added links to social bookmarking/blog indexing sites:  Del.icio.us, Digg, Furl, Google Bookmarks, and Technorati</span><br/>I&#8217;ve published a <a href="http://www.ardamis.com/2007/09/02/fixing-warnings-in-the-wordpress-sociable-plugin/">fix for the Sociable plugin</a>, which I&#8217;m now using instead of hard-coded links</li>
<li>If the <a href="http://www.dagondesign.com/articles/other-posts-from-cat-plugin-for-wordpress/">Other Posts From Cat</a> plugin is active, the theme will use it</li>
<li>Comments by the post&#8217;s author can be styled independently</li>
</ul>
<h3>page.php</h3>
<ul>
<li>Displays the page&#8217;s last modified date (instead of date of publication)</li>
</ul>
<h3>index.php</h3>
<ul>
<li>Displays the full text of the latest post and an excerpt from each of the next nine most recent posts</li>
<li>Native support for <a href="http://guff.szub.net/plugins/">the_excerpt Reloaded</a> plugin, if active</li>
</ul>
<h3>sidebar.php</h3>
<ul>
<li>Displays tag cloud, if tags are enabled</li>
</ul>
<h3>search.php</h3>
<ul>
<li>If no results found, displays the site&#8217;s most recent five posts</li>
</ul>
<h3>404.php</h3>
<ul>
<li>Displays the site&#8217;s most recent five posts</li>
</ul>
<h3>footer.php</h3>
<ul>
<li>Archive and index page titles + blog name wrapped in H1 tags</li>
</ul>
<h3>Screen shot</h3>
<p><a class="hidelink" href="http://www.ardamis.com/images/apricot/apricot_full.png" title="Apricot - A WordPress theme by Ardamis.com"><img class="centered" src="http://www.ardamis.com/images/apricot/apricot_500.png" alt="Apricot - A WordPress theme by Ardamis.com" /></a></p>
<h2>Search engine optimization</h2>
<p>Apricot takes care of most of the on-page factors that Google values highly.  It places the post&#8217;s title at the beginning of the title tag and in a H1 tag near the top of the page.  It is free of extraneous markup and the navigation is easily spiderable.  It generates what I think is a pretty logical site structure from the various post and category pages, though I have yet to study the effect of the new tagging system.</p>
<p>I&#8217;ve had a few top-ranked pages with this and other structurally similar layouts.  Your mileage with the search engines may vary, but the layout uses fundamentally sound structural markup, which should give your site a good start.</p>
<h3>Download</h3>
<p>Download the theme from <a href="http://wordpress.org/extend/themes/apricot">http://wordpress.org/extend/themes/apricot</a> or from the link below.</p>
<p class="download"><a href="http://www.ardamis.com/downloads/apricot.zip">Download the Apricot WordPress Theme</a></p>
<h3>What if I want to use an image as a header?</h3>
<p>Lots of people would rather use a graphic as a header, including me, but the WordPress guys insist on each theme uploaded to <a href="http://wordpress.org/extend/themes/">http://wordpress.org/extend/themes/</a> display the blog title and tag line.</p>
<p>If you want to replace the blog title and tag line with an image, download this zip file and follow these instructions (also included in readme.txt).</p>
<p>1. Make a PNG image, name it &#8220;header.png&#8221; and upload it to the /wp-content/themes/apricot/images/ folder.  It should be 800px wide by 130px tall, or less.</p>
<p>2. Replace the original Apricot theme&#8217;s header.php file with the header.php file from this folder.</p>
<p class="download"><a href="http://www.ardamis.com/downloads/apricot-header-with-image.zip">Download the Apricot Image Header</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ardamis.com/2007/06/03/apricot/feed/</wfw:commentRss>
		<slash:comments>56</slash:comments>
		</item>
		<item>
		<title>Xbox 360 Gamercard WordPress Plugin</title>
		<link>http://www.ardamis.com/2007/03/29/xbox-360-gamercard-wordpress-plugin/</link>
		<comments>http://www.ardamis.com/2007/03/29/xbox-360-gamercard-wordpress-plugin/#comments</comments>
		<pubDate>Thu, 29 Mar 2007 06:51:29 +0000</pubDate>
		<dc:creator>ardamis</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Web Site Dev]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[downloads]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[themes]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://www.ardamis.com/2007/03/29/xbox-360-gamercard-wordpress-plugin/</guid>
		<description><![CDATA[A WordPress plugin that will display a customizable XHTML and CSS Xbox 360 gamer card.]]></description>
			<content:encoded><![CDATA[<div class="success"><strong>Update 2.9.11:</strong> Kevin Fell has taken up the challenge of maintaining this plugin.  Please find the latest release that works with the post January 20, 2011 update at <a href="http://www.kevin-fell.co.uk/development/x-box-360-gamercard-wordpress-plugin/">http://www.kevin-fell.co.uk/development/x-box-360-gamercard-wordpress-plugin/</a>.</div>
<div class="notice"><strong>Update 1.24.11:</strong> I realize the January 20, 2011 update to the gamercard has broken the plugin.  Basically, the plugin expects the HTML of the gamercard to be exactly so, and the HTML of the new card doesn&#8217;t match the plugin&#8217;s expectations.  I don&#8217;t know if I&#8217;ll update the plugin to work with the new gamercard.</div>
<p>I&#8217;ve put together a WordPress plugin that will display a customizable XHTML and CSS Xbox 360 gamer card.  There are plenty of sites out there that will make good looking gamer cards using image files, but this method will give you complete control over the appearance.  It also acts like a gamer card, with a link to your Xbox Live profile and &#8220;compare to&#8221; links to your five most recently played games, something the image file cards can&#8217;t do.</p>
<div id="attachment_900" class="wp-caption aligncenter" style="width: 258px"><a href="http://www.ardamis.com/wp-content/uploads/2007/03/ardamis-xhtml-css-xbox-gamercard-plugin.jpg"><img src="http://www.ardamis.com/wp-content/uploads/2007/03/ardamis-xhtml-css-xbox-gamercard-plugin.jpg" alt="XHTML and CSS Xbox Gamercard WordPress Plugin" title="ardamis-xhtml-css-xbox-gamercard-plugin" width="248" height="247" class="size-full wp-image-900" /></a><p class="wp-caption-text">XHTML and CSS Xbox Gamercard WordPress Plugin</p></div>
<p>For those of you who want a raw PHP script with the same functionality, I&#8217;ve included one farther down in the post.</p>
<h2>How the plugin works</h2>
<p>The plugin uses <a href="http://curl.haxx.se/">cURL</a>, a command line tool for transferring files with URL syntax, to read the contents of your Xbox Live gamer card from http://gamercard.xbox.com/YOURTAG.card into a string, and then uses the PHP function <strong>preg_match</strong> to perform regular expression matching on that string.  The various elements of your gamer card are extracted and then assigned to variables for later output.</p>
<p>The plugin attempts to create a unique text file for each gamertag (gamercard_cache_YOURTAG.txt) for use as a cache in your blog&#8217;s root folder automatically.  This is done to reduce the number of times the target HTML page must be accessed and parsed and therefore reduce server load and page load time.  Some server configurations may not permit the plugin to create this file and you&#8217;ll see resultant errors; in this case, you may have to upload a file with that name and perhaps set permissions on the file.  You can edit the plugin to adjust how old the cache can grow before the script refreshes the information from gamercard.xbox.com.</p>
<h3>Usage</h3>
<p>The plugin accepts two arguments: the first is your gamertag; the second, which is optional, toggles whether the recently played games are displayed.</p>
<p>Insert the code:</p>
<pre class="brush: php; title: ; notranslate">&lt;?php if (function_exists('gamercard')) gamercard('YOURTAG'); ?&gt;</pre>
<p>into a template file wherever you want the gamer card to appear, replacing YOURTAG with your actual Xbox Live gamertag, ex.:</p>
<pre class="brush: php; title: ; notranslate">&lt;?php if (function_exists('gamercard')) gamercard('ardamis'); ?&gt;</pre>
<p>You can include multiple, different gamer cards on each page.</p>
<h3>Customization</h3>
<p>To show the recently played games icons, add the &#8220;full&#8221; argument, ex.:</p>
<pre class="brush: php; title: ; notranslate">&lt;?php if (function_exists('gamercard')) gamercard('ardamis', full); ?&gt;</pre>
<p>Do whatever you want with the CSS to integrate the gamer card into your site.</p>
<h3>Installation</h3>
<p>The download includes:</p>
<ul>
<li>xbox-gamercard.php (put this in your /plugins/ directory)</li>
<li>gamercard.css (copy and paste the contents into your theme&#8217;s style.css)</li>
<li>/gc_images/ (optional &#8211; put this folder of reputation images in your WordPress theme&#8217;s /images/ folder if you want to use them)</li>
</ul>
<p>The plugin by default now uses the gold stars with transparent background from the &#8216;mini-card&#8217; in the top navigation of <a href="http://www.xbox.com/">http://www.xbox.com/</a>.  The rep image is a transparent .png, however.  If you&#8217;re worried that people using IE6 will see an ugly rep because of IE6&#8242;s lack of support for transparent .png, you may want to edit the plugin to use a different rep image.  It&#8217;s easy.</p>
<div class="isolate">
<img style="padding:2px; border: 1px solid #cacaca" src="http://www.ardamis.com/images/xbox-com.jpg" alt="screen shot of mini-card from Xbox.com" /></p>
<p>a screen shot of the &#8216;mini-card&#8217; from Xbox.com</p>
</div>
<p>The optional &#8216;gc_images&#8217; folder contains 20 images, one for each reputation rank, to replace the default gamercard gauge.   They are based on the gauge used in the smaller, menu bar gamercard on the old http://live.xbox.com/ site, but with transparent backgrounds instead of gray for greater flexibility.  You don&#8217;t need to use these, of course.  I&#8217;ve written 3 variables into the plugin if you want to use the official Xbox rep images.  Just edit the plugin to replace <strong>$navgamerrep</strong> in the output with one of the other variables. (Seriously, it&#8217;s easy.)</p>
<h3>Download (beta 1.3)</h3>
<p>Get the files here:</p>
<p class="download"><a href="http://www.ardamis.com/downloads/gamercard-plugin.zip">Download the Xbox 360 Gamer Card WordPress Plugin</a></p>
<h3>I&#8217;m getting an error message</h3>
<p>If your server does not have cURL enabled, you&#8217;ll get an error message that reads something like <strong>Fatal error: Call to undefined function curl_init() in PATH\wp-content\plugins\xbox-gamercard.php on line 54</strong>.  The best solution is to ask your host to enable cURL.  If that option is unavailable, I&#8217;ve provided an alternative that uses the function file_get_contents(), but a number of hosts have disabled the URL retrieving capabilities in file_get_contents() for security reasons.  <a href="http://www.ardamis.com/downloads/gamercard-plugin-fgc.zip">Download the FGC Gamer Card WordPress Plugin</a> only if you&#8217;re getting an error message with the regular download.</p>
<h2>Can I get this as a WordPress Widget?</h2>
<p>Honestly, the plugin is much more flexible than a widget.  Widgets are limited to your sidebar, while the plugin can be used in any template.  Installing the plugin isn&#8217;t very complicated, either.  So, in short, there are no plans to adapt this as a widget right now.</p>
<h2>How can I use this on a non-WordPress site?</h2>
<p class="download"><a href="http://www.ardamis.com/downloads/gamercard-standalone.zip">Download the Xbox 360 Gamer Card Stand-alone Script</a></p>
<p>Just PHP include the xbox-gamercard-standalone.php script wherever you want the card to be displayed, adjusting the path to the reputation images.  Add the contents of gamercard.css to your main CSS file, and modify to suit your site.</p>
<p>Be aware that message boards and forums (eg: vBulletin forums) won&#8217;t allow you to use PHP as part of your post or signature.  In short, don&#8217;t expect this method to work anywhere but on your own site.</p>
<p>You can either edit the script to use your gamertag, or call the script with the line:</p>
<pre class="brush: php; title: ; notranslate">&lt;?php include 'PATH-TO-SCRIPT/xbox-gamercard-standalone.php?tag=YOURTAG'; ?&gt;</pre>
<p>To show the recent games, use:</p>
<pre class="brush: php; title: ; notranslate">&lt;?php include 'PATH-TO-SCRIPT/xbox-gamercard-standalone.php?tag=YOURTAG&amp;full=full'; ?&gt;</pre>
<p>Obviously, you&#8217;ll replace &#8216;YOURTAG&#8217; with your gamertag. If you have any spaces in your gamertag, replace each space with <strong>%20</strong>.</p>
<h3>Further customization (optional)</h3>
<p>A number of neat image and Flash sigs contain way more information than just what&#8217;s provided at http://gamercard.xbox.com/YOURTAG.card, but as far as I can tell, it&#8217;s all gathered in the same way. If there&#8217;s something you&#8217;d like added to the script, find a page that contains the information and post a comment about it, or give programming a shot yourself&#8230;</p>
<p>View the source code of the target page and locate the data you wish to extract.  What we want to do is identify everything <strong>but</strong> the desired data.  Isolate the desired data within the source code of the target page by copying everything from the first character before the data back to and including something unique, such as a div&#8217;s id.  Paste that into a <strong>preg_match</strong> line as the first half of the pattern that the script will look for.  Follow that with the characters <strong>(.+?)</strong>, a bit of code that represents the data we want to extract.  Do not copy the actual desired data from the target page into the modified script.  Last, select and copy a few characters immediately after the data, such as the closing div, and paste that after the <strong>(.+?)</strong>.  Everything in between the two copied strings&#8212;the stuff now represented by the <strong>(.+?)</strong> characters&#8212;will be assigned to a variable.</p>
<h3>Credits</h3>
<p>Thanks to <a href="http://consti.de/">Constantin Hofstetter</a> for getting me started on this project and to Jeremy at <a href="http://www.360gamercards.com/">360gamerCards.com</a> for eliminating the need for the Snoopy script, reducing the process to a single file and otherwise greatly simplifying the whole thing. And thanks to everyone who emailed or posted with error messages and other problems; it&#8217;s a better, more robust plugin because of your efforts.</p>
<p>My gamertag is <strong>ardamis</strong>, should you want to <a href="http://live.xbox.com/en-US/profile/Friends.aspx">add me to your friends list</a> and give me some positive feedback.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ardamis.com/2007/03/29/xbox-360-gamercard-wordpress-plugin/feed/</wfw:commentRss>
		<slash:comments>87</slash:comments>
		</item>
		<item>
		<title>A WordPress Plugin for Title Case Capitalization</title>
		<link>http://www.ardamis.com/2006/09/28/title-case-wordpress-plugin/</link>
		<comments>http://www.ardamis.com/2006/09/28/title-case-wordpress-plugin/#comments</comments>
		<pubDate>Thu, 28 Sep 2006 07:44:34 +0000</pubDate>
		<dc:creator>ardamis</dc:creator>
				<category><![CDATA[Web Site Dev]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[downloads]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.ardamis.com/2006/09/28/wordpress-plugin-for-uppercase-titles/</guid>
		<description><![CDATA[A WordPress plugin for changing the post title to use title case or headline capitalization.  This is not just ucwords or CSS capitalize.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve written a WordPress plugin that will convert the page title and post title to &#8216;title case&#8217; capitalization.  Title case is also often referred to as &#8220;headline style&#8221;, and incorrectly as &#8220;initial caps&#8221; or &#8220;init caps&#8221;.  Title case means that the first letter of each word is capitalized, except for certain small words, such as articles, coordinating conjunctions, and short prepositions.  The first and last words in the title are always capitalized.</p>
<p>This plugin may be useful if you&#8217;re trying to give the titles on your site a consistent appearance, but it&#8217;s no substitute for writing a good title.  There are way too many exceptions and rules to make a simple script behave correctly all of the time.</p>
<p>The plugin is smart enough to not capitalize the following:</p>
<ul>
<li>Coordinating conjunctions (and, but, or, nor, for)</li>
<li>Prepositions of four or fewer letters (with, to, for, at, and so on) (limited)</li>
<li>Articles (a, an, the) unless the article is the first word in the title</li>
</ul>
<p>But the plugin isn&#8217;t perfect.  It won&#8217;t capitalize an article that is the last word in the title.  It fails on subordinating conjunctions.  It conservatively de-capitalizes only some of the prepositions, hopefully reducing the chance of incorrect behavior.  For example, it leaves the word <em>over</em> caps, because <em>over</em> can be an adverb, an adjective, a noun, or a verb (caps) or a preposition (not caps), and determining how a word is being used in a title is really beyond the scope of a humble plugin.</p>
<p>The plugin requires you to edit it for certain product names, like &#8220;iPod&#8221;, and cool-people names, like &#8220;Olivia d&#8217;Abo&#8221; or &#8220;Jimmy McNulty&#8221;.  It&#8217;s not savvy enough to know that acronyms, like &#8220;HTML&#8221;, should be all caps unless they&#8217;re used in particular ways, such as in the case of &#8220;Using the .html Suffix&#8221;, unless you tell it.  That said, editing the plugin for these particular words is very easy.</p>
<p>Even with all these limitations, it beats using CSS to {text-transform: capitalize} the titles or just applying PHP&#8217;s <code>ucwords()</code> to the entire thing.  But I&#8217;m guessing that dissatisfaction with one or both of those two methods is what brought you to this page in the first place.</p>
<p>On the upside, it capitalizes any word following a semicolon or a colon, e.g.: &#8220;Apollo: A Retrospective Analysis&#8221;.   It also capitalizes any word immediately preceded by a double or single quote, but only if you haven&#8217;t bypassed WordPress&#8217;s fancy quotes feature.</p>
<h2>How it works</h2>
<p>The plugin first finds all words that begin with a double or single fancy WordPress quote and adds a space behind the quote.  It capitalizes all of the words in the title with <code>ucwords()</code>, then selectively de-capitalizes some of the words using <code>preg_replace()</code>.  It then uses <code>str_ireplace()</code>, a case-insensitive string replace function, to correct the odd capitalization of certain other words.  Finally, it removes the spaces behind the quotes.</p>
<h2>The code</h2>
<p>This is what the code looks like.  It should be pretty easy to follow what&#8217;s happening.</p>
<pre class="brush: php; title: ; notranslate">&lt;?php

function ardamis_titlecase($title) {
		$title = preg_replace(&quot;/&amp;#8220;/&quot;, '&amp;#8220; ', $title); // find double quotes and add a space behind each instance
 		$title = preg_replace(&quot;/&amp;#8216;/&quot;, '&amp;#8216; ', $title); // find single quotes and add a space behind each instance
		$title = preg_replace(&quot;/(?&lt;=(?&lt;!:|;)\W)(A|An|And|At|But|By|Else|For|From|If|In|Into|Nor|Of|On|Or|The|To|With)(?=\W)/e&quot;,
'strtolower(&quot;$1&quot;)', ucwords($title));  // de-capitalize certain words unless they follow a colon or semicolon
		$specialwords = array(&quot;iPod&quot;, &quot;iMovie&quot;, &quot;iTunes&quot;, &quot;iPhone&quot;, &quot; HTML&quot;, &quot;.html&quot;, &quot; PHP&quot;, &quot;.php&quot;); // form a list of specially treated words
		$title = str_ireplace($specialwords, $specialwords, $title); // replace the specially treated words
		$title = preg_replace(&quot;/&amp;#8220; /&quot;, '&amp;#8220;', $title); // remove the space behind double quotes
		$title = preg_replace(&quot;/&amp;#8216; /&quot;, '&amp;#8216;', $title); // remove the space behind single quotes

		return $title;
}

add_filter('wp_title', 'ardamis_titlecase');
add_filter('the_title', 'ardamis_titlecase');

?&gt;
</pre>
<h2>Download</h2>
<p>Download the plugin, upload it to your site, and activate it.</p>
<p class="download"><a href="http://www.ardamis.com/downloads/ardamis-titlecase.zip">Download the Title Case Capitalization WordPress plugin</a></p>
<h2>Further customization</h2>
<p>The plugin won&#8217;t alter words written in all caps or CamelCase.  You could use <code>ucwords(strtolower($title))</code> to convert the entire <code>$title</code> to lowercase before applying &#8216;ucwords&#8217;.  This may fix instances where someone has typed in a bunch of titles with the caps lock key on.  But you&#8217;ll then have to compensate for words that should be all caps, like &#8216;HTML&#8217;, &#8216;NBC&#8217;, or &#8216;WoW&#8217;, in <code>$specialwords</code>.</p>
<h2>An alternative using a &#8216;foreach&#8217; loop</h2>
<p>It&#8217;s possible to do something similar using a <code>foreach</code> loop.  This isn&#8217;t as graceful, in my opinion, but I suppose it&#8217;s possible that someone may find it works better.</p>
<pre class="brush: php; title: ; notranslate">&lt;?php

function ardamis_titlecase($title) {
	$donotcap = array('a','an','and','at','but','by','else','for','from','if','in','into','nor','of','on','or','the','to','with');
	// Split the string into separate words
	$words = explode(' ', $title);
	foreach ($words as $key =&gt; $word) {
		// Capitalize all but the $donotcap words and the first word in the title
		if ($key == 0 || !in_array($word, $donotcap)) $words[$key] = ucwords($word);
		if (preg_match(&quot;/^&amp;#8220;/&quot;, $word))
			$words[$key] = '&amp;#8220;' . ucwords(substr($word, 7));
		elseif (preg_match(&quot;/^&amp;#8216;/&quot;, $word))
			$words[$key] = '&amp;#8216;' . ucwords(substr($word, 7));
	}
	// Join the words back into a string
	$newtitle = implode(' ', $words);
	return $newtitle;
}

add_filter('wp_title', 'ardamis_titlecase');
add_filter('the_title', 'ardamis_titlecase');

?&gt;
</pre>
<h3>Credits</h3>
<p>Thanks to Chris for insight into the <code>preg_replace</code> code at <a href="http://us2.php.net/ucwords">http://us2.php.net/ucwords</a>.  Thanks to Thomas Rutter for insight into the <code>foreach</code> code at <a href="http://www.sitepoint.com/blogs/2005/03/15/title-case-in-php/">SitePoint Blogs &raquo; Title Case in PHP</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ardamis.com/2006/09/28/title-case-wordpress-plugin/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Optimizing the Syntax in the WordPress Title Tag</title>
		<link>http://www.ardamis.com/2006/07/03/optimizing-the-syntax-in-the-wordpress-title-tag/</link>
		<comments>http://www.ardamis.com/2006/07/03/optimizing-the-syntax-in-the-wordpress-title-tag/#comments</comments>
		<pubDate>Mon, 03 Jul 2006 07:45:22 +0000</pubDate>
		<dc:creator>ardamis</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Site Dev]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[downloads]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[themes]]></category>

		<guid isPermaLink="false">http://www.ardamis.com/2006/07/03/optimizing-the-syntax-in-the-wordpress-title-tag/</guid>
		<description><![CDATA[How to rearrange the elements of the default WordPress title tag to improve SEO.]]></description>
			<content:encoded><![CDATA[<div class="success">This post was written in 2006.  As of WordPress 2.5 (released in 2008), a new <em>seplocation</em> parameter has been added to <a href="http://codex.wordpress.org/Function_Reference/wp_title">wp_title</a>.  This allows you to reverse the page title and blog name in the title tag, in much the same way as I have described in this post.  The page at http://codex.wordpress.org/Function_Reference/wp_title provides this example:</p>
<pre class="brush: php; title: ; notranslate">&lt;title&gt;&lt;?php wp_title('|',true,'right'); ?&gt;&lt;?php bloginfo('name'); ?&gt;&lt;/title&gt;</pre>
<p>I&#8217;d recommend using it, instead of the admittedly complicated instructions below.</p></div>
<p>Getting the title tag just right in WordPress isn&#8217;t as easy as it ought to be.  Currently, a popular title syntax for SEO purposes shows the page&#8217;s title, followed by a pipe separator, followed by the site&#8217;s name.  In practice, this preferred syntax would appear as &#8220;Page Title | Site Name&#8221;.  For whatever reason, the default theme in WordPress has this order reversed, so that each page&#8217;s title starts with the blog name, followed by a &raquo; separator, some useless clutter, another &raquo; separator and then the page&#8217;s title.  The instructions below will help you optimize the title tag to take advantage of the prefered method.</p>
<p>The code for the default WordPress title tag, which is found in the &#8220;header.php&#8221; file, looks like this:</p>
<pre class="brush: php; title: ; notranslate">&lt;title&gt;&lt;?php bloginfo('name'); ?&gt; &lt;?php if ( is_single() ) { ?&gt; &amp;raquo; Blog Archive &lt;?php } ?&gt; &lt;?php wp_title(); ?&gt;&lt;/title&gt;</pre>
<p>It seems like it should be an easy thing to clean up.  We remove the unnecessary &#8220;Blog Archive&#8221; stuff and then switch the two title template tags, putting <code>&lt;?php bloginfo('name'); ?></code> behind <code>&lt;?php wp_title(); ?></code>.</p>
<p>Our title tag code now looks like this:</p>
<pre class="brush: php; title: ; notranslate">&lt;title&gt;&lt;?php wp_title(); ?&gt;&lt;?php bloginfo('name'); ?&gt;&lt;/title&gt;</pre>
<p>But if you make this obvious change and reload one of your blog&#8217;s post pages in your browser, you&#8217;ll notice that the separator, which is inextricably part of the wp_title template tag, wants to be in front of the page title and is now the very first character in your browser&#8217;s title bar, resulting in something like &#8220;&raquo; Page Title Blog Title&#8221;.  Furthermore, we are missing a desired separator between the page title and the blog title.</p>
<p>Let&#8217;s first do something about that initial separator.  The wp_title tag we&#8217;ve been using so far, <code>&lt;?php wp_title(); ?></code>, is abbreviated, meaning that there are some options that are being allowed to fall back to their default states because we haven&#8217;t specifically provided otherwise. Changing the behavior of the wp_title separator is as easy as manipulating these options in the unabbreviated wp_title template tag.  The full tag, including the options, looks something like: <code>&lt;?php wp_title('sep', display); ?></code>, where &#8216;<em>sep</em>&#8216; stands for whatever separator you want and <em>display</em> is either &#8220;true&#8221; or &#8220;false&#8221;, depending on whether you want the title displayed.  For example, if you want to use the pipe symbol &#8221; | &#8221; to appear at the beginning of your post title, you would use: <code>&lt;?php wp_title('|'); ?></code>.  (The display option defaults to &#8220;true&#8221;, which is what we want here, so I&#8217;ll omit that part in the future for the sake of brevity.)</p>
<p>This fiddling with different separators works just fine when the elements of the title are in the default order, but when we put wp_title at the beginning of our title tag, we get a separator as the first character in our title.  We don&#8217;t want a separator in front of the Page Title, so we will use the &#8216;<em>sep</em>&#8216; option described above to tell WordPress to use an empty string (represented by the absence of text between two quotes) as the separator, like so: <code>&lt;?php wp_title(''); ?></code>.  This is the preferred method for removing the leading separator from the wp_title tag.  Now the code for our title tag looks like:</p>
<pre class="brush: php; title: ; notranslate">&lt;title&gt;&lt;?php wp_title(''); ?&gt;&lt;?php bloginfo('name'); ?&gt;&lt;/title&gt;</pre>
<p>This title will cause your browser&#8217;s title bar to display &#8220;Page Title Blog Name&#8221;.  We are getting closer to what we want.</p>
<p>Without explaining exactly how it works, let me just offer you an optional line of code to selectively add or omit a separator between the Page Title and the Blog Name as appropriate for each page: <code>&lt;?php if(wp_title(' ', false)) { echo ' | '; } ?></code>.  Place this line of code between the wp_title and bloginfo template tags, as so:</p>
<pre class="brush: php; title: ; notranslate">&lt;title&gt;&lt;?php wp_title(''); ?&gt;&lt;?php if(wp_title(' ', false)) { echo ' | '; } ?&gt;&lt;?php bloginfo('name'); ?&gt;&lt;/title&gt;</pre>
<p>Reload the page again, and your title bar should show you exactly what we want, &#8220;Page Title | Blog Name&#8221;, without a leading separator.  Any page without a Page Title, the home page, for example, will just have &#8220;Blog Name&#8221; in the title tag.  Everything up to this point is explained on the WordPress Codex page dealing with <a href="http://codex.wordpress.org/Template_Tags/wp_title">Template Tags/wp_title</a>.  For most users, this is as far as one wants or needs to go to achieve the desired result.</p>
<h2>Further optimization</h2>
<p><strong>But&#8230;</strong> if you&#8217;re really humorless about clean code, there&#8217;s more to be done.  If you view the source code of these pages, you&#8217;ll notice that there are a handful of spaces after the opening title tag and before your Page Title.  Yikes.  Lucky for you, I like my code to be tidy and am also pretty interested in SEO, and for both of these reasons, albeit in unequal parts, these leading spaces in the title tag are unacceptable.</p>
<p>There are three ways to make WordPress close up the spaces whenever we declare an empty string as our separator, as in: <code>&lt;?php wp_title(''); ?></code>.  The first method requires editing a file in the WordPress core.  The second method is accomplished by adding a few lines of code to your theme&#8217;s &#8216;functions.php&#8217; file.  The third method uses a simple plugin.</p>
<p>Using any of these methods to remove the spaces will also remove the separator that WP wants to add between the year, month, and DD.MM.YY date of the titles of the monthly archives. So if your separator was a pipe symbol, they looked something like: <strong>2006 | December | 17.12.06 | Ardamis.com</strong> and after removing the spaces they will look like: <strong>2006 December 17.12.06 | Ardamis.com</strong></p>
<h3>Method 1 &#8211; the core file</h3>
<p>This method involves hacking a core file.  This is the most direct way to get the desired result.  It basically corrects the problem the moment it happens.</p>
<h3>For WordPress version 2.2</h3>
<p>The file we want to edit is: \wp-includes\general-template.php.  Open it up and find the following lines (beginning at line 224):</p>
<pre class="brush: php; title: ; notranslate">$prefix = '';
if ( !empty($title) )
	$prefix = &quot; $sep &quot;;
</pre>
<p>Add the line <code>if ( $prefix == '  ' ) { $prefix = ''; }</code> below the block, so that the block now reads:</p>
<pre class="brush: php; title: ; notranslate">$prefix = '';
if ( !empty($title) )
	$prefix = &quot; $sep &quot;;

if ( $prefix == '  ' ) { $prefix = ''; }
</pre>
<h3>Method 2 &#8211; functions.php</h3>
<p>If you&#8217;re not comfortable editing a core file, and if you don&#8217;t want to install yet another plugin, this method will also work.  Open the &#8216;functions.php&#8217; file in your theme folder and add the following lines.  Depending on your theme, functions.php may already contain some PHP code; that&#8217;s ok, just tuck this in at the end.  The first line of functions.php should be <code>&lt;?php</code> and the last line should be <code>?></code>.  If those lines don&#8217;t exist, add them and then add the following code between them.</p>
<pre class="brush: php; title: ; notranslate">function af_titledespacer($title) {
	return trim($title);
}

add_filter('wp_title', 'af_titledespacer');
</pre>
<h3>Method 3 &#8211; a plugin</h3>
<p>If plugins are more your speed, you can get the same results with my Despacer plugin.</p>
<p class="download"><a href="http://www.ardamis.com/downloads/ardamis-despacer.zip">Download the Despacer WordPress plugin</a></p>
<h3>Utilizing the changes in the template files</h3>
<p>We can now remove the separator and the annoying blank spaces on an instance-by-instance basis by specifying an empty string as the separator, as so: <code>&lt;?php wp_title(''); ?></code>.  By way of example, to hide the separator and remove the blank spaces, a &#8220;Page Title | Blog Name&#8221; title tag would look like:</p>
<pre class="brush: php; title: ; notranslate">&lt;title&gt;&lt;?php wp_title(''); ?&gt;&lt;?php if(wp_title(' ', false)) { echo ' | '; } ?&gt;&lt;?php bloginfo('name'); ?&gt;&lt;/title&gt;</pre>
<p>If anyone finds a better way of arriving at this result, preferably entirely within the template files, please leave me a comment, or post to the <a href="http://wordpress.org/support/topic/44741">WordPress support forum</a>.</p>
<p>You may notice that one poster to the WordPress forums suggests that the search engines don&#8217;t care if there is white space in a web page.  While I agree that the search engines and browsers don&#8217;t have any problem parsing pages that contain chunks of white space, a gap at the beginning of the title tag looks very unnatural to me.  No human would intentionally add a bunch of blank spaces to the beginning of the tag, and it&#8217;s generally understood that for SEO purposes, a page that looks handcrafted is superior to one that looks like it has been slapped together by a script.  This may not be a problem now, but Google and the other search engines are constantly working to remove spam/garbage/scraped sites from their results, and they may one day use weirdly unnatural artifacts like this to identify them.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ardamis.com/2006/07/03/optimizing-the-syntax-in-the-wordpress-title-tag/feed/</wfw:commentRss>
		<slash:comments>41</slash:comments>
		</item>
	</channel>
</rss>

