<?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>Alex Mansfield &#187; Wordpress</title>
	<atom:link href="http://alexmansfield.com/category/wordpress/feed" rel="self" type="application/rss+xml" />
	<link>http://alexmansfield.com</link>
	<description>WordPress Developer</description>
	<lastBuildDate>Tue, 28 Feb 2012 23:24:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Change Default Media Settings on Theme Activation</title>
		<link>http://alexmansfield.com/wordpress/media-settings-theme-activation</link>
		<comments>http://alexmansfield.com/wordpress/media-settings-theme-activation#comments</comments>
		<pubDate>Thu, 03 Nov 2011 18:06:43 +0000</pubDate>
		<dc:creator>alexmansfield</dc:creator>
				<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://alexmansfield.com/?p=649</guid>
		<description><![CDATA[Let&#8217;s face it, if you&#8217;re a developer you want to make things as simple as possible for your clients. One way to do this is to set the default media sizes when your theme is activated. Your users should never need to try to figure out the width of the content area. They shouldn&#8217;t have [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s face it, if you&#8217;re a developer you want to make things as simple as possible for your clients. One way to do this is to set the default media sizes when your theme is activated. Your users should never need to try to figure out the width of the content area. They shouldn&#8217;t have find where the default settings are located. They shouldn&#8217;t have to worry about any of that. When they upload an image or use an embed code, the correct sizes should already be set. Here&#8217;s how you can do that for them.</p>
<p><span id="more-649"></span></p>
<pre class="brush: php; title: ; notranslate">// Reset default media sizes
if ( is_admin() &amp;&amp; isset( $_GET['activated'] ) &amp;&amp; $pagenow == 'themes.php' ){
	global $wpdb;
	$wpdb-&gt;query(&quot;UPDATE $wpdb-&gt;options SET option_value='200' WHERE option_name='thumbnail_size_w'&quot;);
	$wpdb-&gt;query(&quot;UPDATE $wpdb-&gt;options SET option_value='200' WHERE option_name='thumbnail_size_h'&quot;);
	$wpdb-&gt;query(&quot;UPDATE $wpdb-&gt;options SET option_value='1' WHERE option_name='thumbnail_crop'&quot;);

	$wpdb-&gt;query(&quot;UPDATE $wpdb-&gt;options SET option_value='400' WHERE option_name='medium_size_w'&quot;);
	$wpdb-&gt;query(&quot;UPDATE $wpdb-&gt;options SET option_value='400' WHERE option_name='medium_size_h'&quot;);

	$wpdb-&gt;query(&quot;UPDATE $wpdb-&gt;options SET option_value='800' WHERE option_name='large_size_w'&quot;);
	$wpdb-&gt;query(&quot;UPDATE $wpdb-&gt;options SET option_value='800' WHERE option_name='large_size_h'&quot;);

	$wpdb-&gt;query(&quot;UPDATE $wpdb-&gt;options SET option_value='800' WHERE option_name='embed_size_w'&quot;);
	$wpdb-&gt;query(&quot;UPDATE $wpdb-&gt;options SET option_value='0' WHERE option_name='embed_size_h'&quot;);
	$wpdb-&gt;query(&quot;UPDATE $wpdb-&gt;options SET option_value='1' WHERE option_name='embed_autourls'&quot;);
}</pre>
<p>This piece of code goes in the functions.php file of the theme. When the theme is activated, it sets all the default media sizes available on the Settings > Media page. Feel free to remove any lines that you don&#8217;t need. Then change the remaining values to fit the size of your theme and you&#8217;re ready to go! </p>
]]></content:encoded>
			<wfw:commentRss>http://alexmansfield.com/wordpress/media-settings-theme-activation/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>WordPress Taxonomy Tabs</title>
		<link>http://alexmansfield.com/wordpress/wordpress-taxonomy-tabs</link>
		<comments>http://alexmansfield.com/wordpress/wordpress-taxonomy-tabs#comments</comments>
		<pubDate>Tue, 01 Nov 2011 16:47:26 +0000</pubDate>
		<dc:creator>alexmansfield</dc:creator>
				<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://alexmansfield.com/?p=628</guid>
		<description><![CDATA[Jason Schuller of Press75.com mentioned on Twitter yesterday that the taxonomy UI in the WordPress admin could use some improvement. I thought that sounded like a good idea, so I went about figuring out how such a change could be made. In the end, it took three sections of code, all of which can be [...]]]></description>
			<content:encoded><![CDATA[<p>Jason Schuller of <a title="Press 75" href="http://press75.com/">Press75.com</a> mentioned on Twitter yesterday that the taxonomy UI in the WordPress admin could use some improvement.</p>
<!-- tweet id : 131088144706707456 --><style type='text/css'>#bbpBox_131088144706707456 a { text-decoration:none; color:#7d7d7d; }#bbpBox_131088144706707456 a:hover { text-decoration:underline; }</style><div id='bbpBox_131088144706707456' class='bbpBox' style='padding:20px; margin:5px 0; background-color:#19191b; background-image:url(http://a0.twimg.com/profile_background_images/305736835/bg.jpg);'><div style='background:#fff; padding:10px; margin:0; min-height:48px; color:#666666; -moz-border-radius:5px; -webkit-border-radius:5px;'><span style='width:100%; font-size:18px; line-height:22px;'>In regards to custom taxonomies, it would be nice to have just one tabbed box within the editor instead a separate box for each taxonomy.</span><div class='bbp-actions' style='font-size:12px; width:100%; padding:5px 0; margin:0 0 10px 0; border-bottom:1px solid #e6e6e6;'><img align='middle' src='http://alexmansfield.com/wpress/wp-content/plugins/twitter-blackbird-pie//images/bird.png' /><a title='tweeted on October 31, 2011 7:20 pm' href='http://twitter.com/#!/jschuller/status/131088144706707456' target='_blank'>October 31, 2011 7:20 pm</a> via <a href="http://twitterrific.com" rel="nofollow" target="blank">Twitterrific for Mac</a><a href='https://twitter.com/intent/tweet?in_reply_to=131088144706707456' class='bbp-action bbp-reply-action' title='Reply'><span><em style='margin-left: 1em;'></em><strong>Reply</strong></span></a><a href='https://twitter.com/intent/retweet?tweet_id=131088144706707456' class='bbp-action bbp-retweet-action' title='Retweet'><span><em style='margin-left: 1em;'></em><strong>Retweet</strong></span></a><a href='https://twitter.com/intent/favorite?tweet_id=131088144706707456' class='bbp-action bbp-favorite-action' title='Favorite'><span><em style='margin-left: 1em;'></em><strong>Favorite</strong></span></a></div><div style='float:left; padding:0; margin:0'><a href='http://twitter.com/intent/user?screen_name=jschuller'><img style='width:48px; height:48px; padding-right:7px; border:none; background:none; margin:0' src='http://a0.twimg.com/profile_images/1440849860/jason-cropped_normal.jpg' /></a></div><div style='float:left; padding:0; margin:0'><a style='font-weight:bold' href='http://twitter.com/intent/user?screen_name=jschuller'>@jschuller</a><div style='margin:0; padding-top:2px'>Jason Schuller</div></div><div style='clear:both'></div></div></div><!-- end of tweet -->
<p>I thought that sounded like a good idea, so I went about figuring out how such a change could be made. <span id="more-628"></span> In the end, it took three sections of code, all of which can be placed within your theme&#8217;s functions.php file if you&#8217;re hoping to test it out. Ideally, this change belongs in a plugin rather than a theme file, but I&#8217;m not going to get into that discussion today. Here&#8217;s the first section of code:</p>
<pre class="brush: php; title: ; notranslate">// Load the jQuiry UI tabs script
wp_enqueue_script( 'jquery-ui-tabs' );</pre>
<p>All it does is load the jQuery UI tabs script that will help us create the taxonomy tabs. The file itself is packaged with WordPress, so we don&#8217;t have to specify where it resides. Next we have the script that creates the tabbed taxonomies area.</p>
<pre class="brush: php; title: ; notranslate">// Create new taxonomy tabs box and move current taxonomies into the new box
function custom_scripts() {
	?&gt;
		&lt;script type='text/javascript'&gt;
			jQuery(document).ready(function() {
				if(jQuery('.categorydiv').length != 0){
					var element = jQuery('&lt;div id=&quot;tax-tabs&quot; class=&quot;postbox&quot;&gt;&lt;h3 class=&quot;hndl&quot;&gt;Taxonomies&lt;/h3&gt;&lt;div id=&quot;tabs&quot;&gt;&lt;ul id=&quot;tab-nav&quot;&gt;&lt;/ul&gt;&lt;div id=&quot;tax-tabs-inside&quot; class=&quot;inside&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;');
					jQuery(element).appendTo('#side-sortables');
					jQuery('.categorydiv').each(function(index) {
						jQuery(this).parents('.postbox').css('display', 'none');
						var title = jQuery(this).parents('.postbox').children('.hndle').children('span').html();
						var slug = jQuery(this).parents('.postbox').attr('ID');
						var slug = slug.replace('div', '');
						jQuery('&lt;li&gt;&lt;a href=&quot;#taxonomy-' + slug + '&quot;&gt;' + title + '&lt;/a&gt;&lt;/li&gt;').appendTo('#tab-nav');
						jQuery(this).appendTo('#tax-tabs-inside');
					});

					jQuery(function() {
						jQuery( &quot;#tabs&quot; ).tabs();
					});
				}
			});
		&lt;/script&gt;
	&lt;?php
}
add_action('admin_head', 'custom_scripts');</pre>
<p>This function writes out the Javascript involved with adding a new section to the WordPress page/post editor. It begins by checking if any taxonomies exist (keep in mind that &#8220;Categories&#8221; are a built-in taxonomy). If there are, the taxonomy box is displayed. After this, we loop through all the &#8220;.categorydiv&#8221; elements and move them into our new taxonomy box, writing the tabbed navigation as we go. Finally, we need to add a few styles so that the tabs look like tabs and the whole box blends with the default WordPress experience:</p>
<pre class="brush: php; title: ; notranslate">// Style new taxonomy tabs
function custom_styles() {
	?&gt;
		&lt;style type=&quot;text/css&quot;&gt;
			.ui-tabs-nav{
				background: #ededed;
				border-bottom: 1px solid #dfdfdf !important;
				margin-top: -6px !important;
				padding: 0 0 0 9px !important;
			}
			.ui-tabs-nav a{
				display:block;
				float:left;
				padding: 5px;
				margin:5px 0 0 0;
				text-decoration:none;
				}
			.ui-tabs-nav .ui-tabs-selected a{
				background: #f9f9f9;
				border: 1px solid #dfdfdf;
				border-bottom:0;
				color: #333;
				margin-bottom: -1px;
				-moz-border-radius: 3px 3px 0px 0px;
				-webkit-border-radius: 3px 3px 0px 0px;
				border-radius: 3px 3px 0px 0px;
			}
		&lt;/style&gt;
	&lt;?php
}
add_action('admin_head', 'custom_styles');</pre>
<p>Please note: I have only tested this in Firefox and Chrome. There may be CSS issues with Internet Explorer. If you run into any difficulties setting this up, feel free to speak up in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://alexmansfield.com/wordpress/wordpress-taxonomy-tabs/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Setting the Default Editor for a Custom Post Type</title>
		<link>http://alexmansfield.com/wordpress/default-editor-custom-post-type</link>
		<comments>http://alexmansfield.com/wordpress/default-editor-custom-post-type#comments</comments>
		<pubDate>Fri, 07 Oct 2011 20:33:59 +0000</pubDate>
		<dc:creator>alexmansfield</dc:creator>
				<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://alexmansfield.com/?p=595</guid>
		<description><![CDATA[Recently I was working on a project where I was writing some PHP and HTML source code documentation and publishing it via WordPress. As you may know, the WordPress visual editor isn&#8217;t ideal when it comes to handling such code. Consequently, I went looking for a way to set the default editor to HTML rather [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I was working on a project where I was writing some PHP and HTML source code documentation and publishing it via WordPress. As you may know, the WordPress visual editor isn&#8217;t ideal when it comes to handling such code. Consequently, I went looking for a way to set the default editor to HTML rather than Visual. However, I didn&#8217;t want to cause the HTML editor to be the default across the entire site, so I created a custom post type for my code documentation. Then I changed the default editor for only that post type with the following piece of code:</p>
<pre class="brush: php; title: ; notranslate">add_filter('wp_default_editor', 'set_default_editor');

function set_default_editor( $type ) {
    global $post_type;
    if('code-doc' == $post_type)
        return 'html';
    return $type;
}</pre>
<p>All you need to do to use this piece of code is change &#8220;code-doc&#8221; to reflect the name of your custom post type.</p>
]]></content:encoded>
			<wfw:commentRss>http://alexmansfield.com/wordpress/default-editor-custom-post-type/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The WordPress &#8220;More&#8221; Tag</title>
		<link>http://alexmansfield.com/blogging/wordpress-more-tag</link>
		<comments>http://alexmansfield.com/blogging/wordpress-more-tag#comments</comments>
		<pubDate>Fri, 10 Jun 2011 06:29:22 +0000</pubDate>
		<dc:creator>alexmansfield</dc:creator>
				<category><![CDATA[Blogging]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://alexmansfield.com/?p=567</guid>
		<description><![CDATA[Those of you who know WordPress like the back of your hand, please feel free to skip this post. It is simply an explanation of the &#8220;More&#8221; tag used by WordPress post editor. The &#8220;More&#8221; tag is used to let WordPress know just how much of each post should be displayed on multiple post pages [...]]]></description>
			<content:encoded><![CDATA[<p>Those of you who know WordPress like the back of your hand, please feel free to skip this post. It is simply an explanation of the &#8220;More&#8221; tag used by WordPress post editor. The &#8220;More&#8221; tag is used to let WordPress know just how much of each post should be displayed on multiple post pages (for example: the home page, category pages, tag pages, search pages, etc. where you might not want to display the entire post). WordPress will start at the beginning of a post and display everything until it runs into the &#8220;More&#8221; tag. When it reaches the &#8220;More&#8221; tag, it will insert a &#8220;Continue Reading&#8230;&#8221; link and move on to the next post. Just below this paragraph there is a screen shot of the &#8220;More&#8221; tag in action. The upper circle is surrounding the &#8220;More&#8221; button, while the lower circle is demonstrating the visible result of the &#8220;More&#8221; button from within the post editor. To use the more tag, simply place your cursor at the desired location and click the &#8220;More&#8221; button. Easy as that!</p>
<p><a href="http://alexmansfield.com/wpress/wp-content/uploads/2011/06/more.jpeg"><img class="alignnone size-full wp-image-569" title="more" src="http://alexmansfield.com/wpress/wp-content/uploads/2011/06/more.jpeg" alt="" width="700" height="280" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://alexmansfield.com/blogging/wordpress-more-tag/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sackcloth Studios Redesign</title>
		<link>http://alexmansfield.com/general/sackcloth-redesign</link>
		<comments>http://alexmansfield.com/general/sackcloth-redesign#comments</comments>
		<pubDate>Thu, 24 Feb 2011 01:39:02 +0000</pubDate>
		<dc:creator>alexmansfield</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://alexmansfield.com/?p=422</guid>
		<description><![CDATA[It&#8217;s been a few years since I first launched sackclothstudios.com (my business site) and it was beginning to show it&#8217;s age. The newest post on the blog was over a year old and the site just needed a little love. I figured while I was at it, I might as well document the process. Planning [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a few years since I first launched <a href="http://sackclothstudios.com">sackclothstudios.com</a> (my business site) and it was beginning to show it&#8217;s age. The newest post on the blog was over a year old and the site just needed a little love. I figured while I was at it, I might as well document the process.</p>
<p><span id="more-422"></span><br />
<h3>Planning</h3>
<p>I knew that I wanted something at least a little more unique. My previous design was nice enough, but it wasn&#8217;t really that different from any number of other sites floating around cyberspace. One of the first design elements I settled on was a bottom aligned header. Rather than place my logo and navigation at the top of the page, I would fix it to the bottom of the browser window. It seems to work well in all browsers except embedded Safari.</p>
<p>The other thing I knew I wanted to change was the blog. Since I started <a href="http://alexmansfield.com">alexmansfield.com</a>, I didn&#8217;t have much use for the Sackcloth Studios blog. So with the new site design, the blog is replaced by my portfolio. I might add a more traditional blog again in the future, but for the moment I think the portfolio will be just fine. I only had a couple posts on the old blog that got many links, so I re-published them here and redirected the old pages here.</p>
<h3>Design</h3>
<p>I already mentioned the bottom aligned header. After that I decided to make extensive use of the @font-face css property. I chose to use the <a href="http://www.josbuivenga.demon.nl/museo.html">Museo</a> font by <a href="http://www.josbuivenga.demon.nl/index.html">Jos Buivenga</a>, which I had already used sparingly in my first design. Next I decided to use a small background image in the lower right hand corner. As I started to build the site, I realized I didn&#8217;t need a sidebar. This left more room for the background image even at smaller screen sizes. The footer was also unnecessary. Finally, I found a nicely drawn <a href="http://icons.mysitemyway.com/category/magic-marker-icons/">Magic Marker</a> icon set with more icons than I could ever dream of using. Part way through the design process I changed the background color from white to light gray, which really helped give the site the look I was going for.</p>
<h3>Development</h3>
<p>When I first started building the theme, I planned on using the new custom post types feature for the portfolio. However, the more I worked with it, the more I realized that old fashioned categories were the best tool for the job. For the portfolio posts, I decided to display the screenshots by looping through all the images associated with the post. That makes adding an image as simple as can be. I can just go to the post, upload an image, and it will automatically show up on the page. However, this became a problem when I decided to use thumbnails on the portfolio category page. If I uploaded a thumbnail, it would automatically show up on the post page, even if I didn&#8217;t want it to be displayed there. To solve this problem, I used this handy little piece of code.</p>
<pre class="brush: php; title: ; notranslate">$attachments = get_posts($args);
if ($attachments) {&lt;br /&gt;   foreach ($attachments as $attachment) {
      if ($attachment-&gt;ID != get_post_thumbnail_id()){
         $image = get_image_by_id($attachment-&gt;ID);
         echo '&lt;img src=&quot;' . $image-&gt;src . '&quot; alt=&quot;'. $image-&gt;alt . '&quot;&gt;';
      }
   }
}</pre>
<p>As it&#8217;s looping through the images, it checks to make sure it&#8217;s not the thumbnail image before displaying it. Problem solved! The last little touch was adding support for custom background images. My face is on the home page, but I really didn&#8217;t want it on every page, so I added a custom field where I could specify the location of an image to be used for individual posts.</p>
<h3>Plugins</h3>
<p>Gravity Forms<br /> &#8211; <a href="https://www.e-junkie.com/ecom/gb.php?cl=54585&amp;c=ib&amp;aff=123038">http://gravityforms.com</a></p>
<p>I decided to use the Gravity Forms plugin to handle the contact form. It was a snap to set up and it does everything I could ask for (and probably quite a bit more).</p>
<p>Limit Login Attempts<br /> &#8211; <a href="http://devel.kostdoktorn.se/limit-login-attempts/">http://devel.kostdoktorn.se/limit-login-attempts/</a><br /> &#8211; <a href="http://wordpress.org/extend/plugins/limit-login-attempts/">http://wordpress.org/extend/plugins/limit-login-attempts/</a></p>
<p>This simply limits the number of failed login attempts that can happen before blocking a user. This prevents trial and error attempts at compromising the login.</p>
<p>Google Analytics for WordPress<br /> &#8211; <a href="http://yoast.com/wordpress/google-analytics/">http://yoast.com/wordpress/google-analytics/</a><br /> &#8211; <a href="http://wordpress.org/extend/plugins/google-analytics-for-wordpress/">http://wordpress.org/extend/plugins/google-analytics-for-wordpress/</a></p>
<p>A great plugin from Joost de Valk that handles everything imaginable relating to Google Analytics and WordPress.</p>
<p>W3 Total Cache<br /> &#8211; <a href="http://www.w3-edge.com/wordpress-plugins/w3-total-cache/">http://www.w3-edge.com/wordpress-plugins/w3-total-cache<br /> </a>- <a href="http://wordpress.org/extend/plugins/w3-total-cache/">http://wordpress.org/extend/plugins/w3-total-cache/</a></p>
<p>Simply the best caching plugin I&#8217;ve come across so far.</p>
<h3>Implementation</h3>
<p>I didn&#8217;t do too much out of the ordinary here. I had a few posts that I wanted to keep for future reference, but I didn&#8217;t want to publish theme here, so I tried using the <a href="http://wordpress.org/extend/plugins/pdf24-post-to-pdf/">PDF24 Article To PDF</a> plugin to create PDF documents of the posts. It worked great, but it left out all the code blocks, so I ended up backing them up manually. I thought about using the <a href="http://wordpress.org/extend/plugins/development-theme-test/">Development Theme Test</a> plugin to test the new theme on the old WordPress installation, but in the end I decided to just start from scratch. So from there all I had to do was install WordPress (3.0 RC) in a subdirectory (see <a href="http://alexmansfield.com/wordpress/wordpress-in-a-subdirectory">Installing WordPress in a Subdirectory</a>), upload the theme, add content, and set the new installation to take over for the old one.</p>
<p>If you have any questions about the process, feel free to <a href="http://alexmansfield.com/contact/">contact me</a> or post a comment below.</p>
]]></content:encoded>
			<wfw:commentRss>http://alexmansfield.com/general/sackcloth-redesign/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple PHP Redirect in WordPress</title>
		<link>http://alexmansfield.com/hacks/php-redirect-wordpress</link>
		<comments>http://alexmansfield.com/hacks/php-redirect-wordpress#comments</comments>
		<pubDate>Thu, 17 Jun 2010 21:35:21 +0000</pubDate>
		<dc:creator>alexmansfield</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://alexmansfield.com/?p=429</guid>
		<description><![CDATA[Note: This post was originally written for my blog over at sackclothstudios.com. However, with the changes I&#8217;m making to that site, I figured the post would be of more use here on this site. Sometimes when using WordPress you want to include a non-Wordpress page in your main navigation while still maintaining the simplicity of [...]]]></description>
			<content:encoded><![CDATA[<p>Note: This post was originally written for my blog over at <a href="http://sackclothstudios.com">sackclothstudios.com</a>. However, with the changes I&#8217;m making to that site, I figured the post would be of more use here on this site.</p>
<p>Sometimes when using WordPress you want to include a non-Wordpress page in your main navigation while still maintaining the simplicity of the <strong>wp_list_pages()</strong> function. I know there are plugins that do this type of thing, but many of them are just overkill. I just needed one non-Wordpress page on my menu, so here’s what I did. First, I created a page from within WordPress and gave it a heading but left the body blank. My page was called “Purchase” but you can name it whatever you’d like. This is the name that will show up in your navigation menu. Then I went to the header.php file of my theme and added this at the top:</p>
<pre class="brush: php; title: ; notranslate">&lt;?php
if(is_page('purchase')){
header(&quot;HTTP/1.1 301 Moved Permanently&quot;);
header(&quot;Status: 301 Moved Permanently&quot;);
header(&quot;Location: http://www.example.com/&quot;);
header(&quot;Connection: close&quot;);
exit(0); // Optional, prevents any accidental output
}
?&gt;</pre>
<div>
<p>Obiously, you’ll want to change the <strong>if</strong> statement to check for the blank page that you set up. Then change “http://www.example.com/” to whatever page you want the redirect to point to. Make sure that you put the code at the very top of the header.php file. If something else comes before it, it won’t work.</p>
<p>I first found this PHP redirect on  <a href="http://www.stevenhargrove.com/redirect-web-pages/">Steven Hargrove’s blog</a>.  He gives examples of this in a number of different languages. However, I adapted it to WordPress and added the ” header( “Connection: close”);” line to get it working properly. I’d love to hear how you solve this little WordPress problem. If you have a different solution, please leave a comment below with a brief explaination. Thanks.</p>
<p>Update: If you want to make a temporary redirect (302), rather than a permanent one (301) use the code below:</p>
<pre class="brush: php; title: ; notranslate">&lt;?php
if(is_page('purchase')){
header(&quot;Location: http://www.example.com/&quot;);
header(&quot;Connection: close&quot;);
exit(0); // Optional, prevents any accidental output
}
?&gt;</pre>
</div>
<div><a href="http://dubaijobs101.blogspot.com/">Algen</a> asked if it was possible to do a delayed redirect. It is possible, but not with PHP. Here is the HTML necessary to redirect a page after 30 seconds:</div>
<div>
<pre class="brush: php; title: ; notranslate">&lt;meta http-equiv=&quot;refresh&quot; content=&quot;10;url=http://www.example.php&quot;&gt;</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://alexmansfield.com/hacks/php-redirect-wordpress/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Sanitary Theme 0.2</title>
		<link>http://alexmansfield.com/themes/sanitary-theme-0-2</link>
		<comments>http://alexmansfield.com/themes/sanitary-theme-0-2#comments</comments>
		<pubDate>Fri, 16 Apr 2010 06:21:23 +0000</pubDate>
		<dc:creator>alexmansfield</dc:creator>
				<category><![CDATA[Themes]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://alexmansfield.com/?p=403</guid>
		<description><![CDATA[It has been 10 months to the day since I released Sanitary 0.1, a clean starting point for developing WordPress themes. An update is obviously overdue, so even though it will need to be updated again as soon as WordPress 3.0 comes out, I&#8217;m releasing Sanitary 0.2. It is still a work in progress, but [...]]]></description>
			<content:encoded><![CDATA[<p>It has been 10 months to the day since I released Sanitary 0.1, a clean starting point for developing WordPress themes. An update is obviously overdue, so even though it will need to be updated again as soon as WordPress 3.0 comes out, I&#8217;m releasing Sanitary 0.2. It is still a work in progress, but as you can see from the changelog, there have been quite a few changes under the hood. The change that I&#8217;m most excited about is the move to HTML5, with support for even Internet Explorer (Thanks to Remy Sharp&#8217;s HTML5 enabling script). <a href="http://alexmansfield.com/wpress/wp-content/uploads/2010/04/sanitary.zip">Download Sanitary 0.2</a></p>
<p>Here&#8217;s the changelog:</p>
<p>deleted<br />
- searchform.php<br />
- categories.php<br />
- archive.php<br />
- archives.php</p>
<p>functions.php<br />
- added thumbnail support</p>
<p>single.php<br />
- changed h2 to h1 (single.php)</p>
<p>search.php<br />
- replaced the seachform call with a form</p>
<p>404.php<br />
- replaced the seachform with a widget area</p>
<p>archives.php<br />
- replaced the seachform call with a form</p>
<p>archive.php<br />
- replaced the seachform call with a form</p>
<p>comments.php<br />
- added anchor tag to comments heading to allow links to the comments section (url.com/example.html#comments)<br />
- added &lt;small&gt; tags around allowed tags<br />
- removed double reference to number of comments<br />
- changed ids to match names for comment form<br />
- added label for comment textbox<br />
- removed the &#8220;(required)&#8221; message from the &#8220;Name&#8221; and &#8220;Mail&#8221; labels (Not sure about this decision. Input welcome.)<br />
- Changed &#8220;Mail&#8221; label to &#8220;Email&#8221;</p>
<p>all over the place<br />
- added underscores to many ids (.post_meta, .post_navigation #comments_form)<br />
- converted to html5 and included javascript to allow older browsers to render new tags properly<br />
(<a href="http://remysharp.com/2009/01/07/html5-enabling-script/">http://remysharp.com/2009/01/07/html5-enabling-script/</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://alexmansfield.com/themes/sanitary-theme-0-2/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WordPress Single Category Search</title>
		<link>http://alexmansfield.com/wordpress/category-search</link>
		<comments>http://alexmansfield.com/wordpress/category-search#comments</comments>
		<pubDate>Mon, 07 Sep 2009 16:39:19 +0000</pubDate>
		<dc:creator>alexmansfield</dc:creator>
				<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://alexmansfield.com/?p=309</guid>
		<description><![CDATA[Sometimes it comes in handy to make the search form on a blog only return results from a single category. It&#8217;s actually quite simple. 1. Find the category ID First we need to find the ID of the category that we want to search. We can find that by going to Posts&#62;Categories and hovering over [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-372" title="custom-search" src="http://alexmansfield.com/wpress/wp-content/uploads/2009/08/custom-search.jpg" alt="custom-search" width="560" height="215" /></p>
<p>Sometimes it comes in handy to make the search form on a blog only return results from a single category. It&#8217;s actually quite simple.</p>
<h3>1. Find the category ID</h3>
<p>First we need to find the ID of the category that we want to search. We can find that by going to Posts&gt;Categories and hovering over the category we want to search in the categories list on the right side of the page. When we hover the mouse over a category, we’ll see something like this in the status bar (usually the bottom left corner of the browser):</p>
<p><strong>&#8230;/wp-admin/categories.php?action=edit&amp;cat_ID=3</strong></p>
<p>As you can probably see, the 3 at the end is the category ID. That number is all we need to know.</p>
<h3>2. Edit the searchform.php file</h3>
<p>We just need to find this line in the searchform.php file of the theme:</p>
<pre class="brush: xml; title: ; notranslate">&lt;form method=&quot;get&quot; id=&quot;searchForm&quot; action=&quot;&lt;?php bloginfo('home'); ?&gt;/&quot;&gt;</pre>
<p>and add this hidden field immediately after it:</p>
<pre class="brush: xml; title: ; notranslate">&lt;input type=&quot;hidden&quot; name=&quot;cat&quot; id=&quot;cat&quot; value=&quot;3&quot;/&gt;</pre>
<h3>3. Apply the category ID</h3>
<p>Now we need to make sure that we change the value of the hidden field to the category ID we found in step one. For example, if the category we chose had an ID of 12, then the hidden field would look like this:</p>
<pre class="brush: xml; title: ; notranslate">&lt;input type=&quot;hidden&quot; name=&quot;cat&quot; id=&quot;cat&quot; value=&quot;12&quot;/&gt;</pre>
<p>It&#8217;s that easy! If you have any questions, feel free to post them in the comments section below.</p>
<p>Image by <a href="http://www.flickr.com/photos/28201168@N06/2981863687/">rockmixer</a></p>
]]></content:encoded>
			<wfw:commentRss>http://alexmansfield.com/wordpress/category-search/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>WordPress Plugin: Latest Posts by Author</title>
		<link>http://alexmansfield.com/plugins/latest-posts-by-author</link>
		<comments>http://alexmansfield.com/plugins/latest-posts-by-author#comments</comments>
		<pubDate>Tue, 11 Aug 2009 23:52:59 +0000</pubDate>
		<dc:creator>alexmansfield</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://alexmansfield.com/?p=377</guid>
		<description><![CDATA[Update: The plugin has gone through a number of revisions since I first published this post. See: http://wordpress.org/extend/plugins/latest-posts-by-author/ for the latest versions. The code posted below is from version 0.6. I just posted my first plugin to wordpress.org. It creates an unordered list of the most recent posts by a given author. It can be [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update</strong>: The plugin has gone through a number of revisions since I first published this post. See: <a href="http://wordpress.org/extend/plugins/latest-posts-by-author/">http://wordpress.org/extend/plugins/latest-posts-by-author/</a> for the latest versions. The code posted below is from version 0.6.</p>
<p>I just posted my first plugin to <a href="http://wordpress.org/">wordpress.org</a>. It creates an unordered list of the most recent posts by a given author. It can be called both from within a post using a shortcode or from within a theme file. Check out <a href="http://wordpress.org/extend/plugins/latest-posts-by-author/">Latest Posts by Author</a> at wordpress.org for more details.</p>
<p>To demonstrate just how easy it is to create a plugin for WordPress, I&#8217;m posting the plugin code below.</p>
<pre class="brush: php; title: ; notranslate">&lt;?php

/*
Plugin Name: Latest Posts by Author
Plugin URI: http://wordpress.org/#
Description: Displays a list of recent posts by the specified author
Author: Alex Mansfield
Version: 0.6
Author URI: http://alexmansfield.com/
*/

function latest_posts_by_author($array) {
 extract(shortcode_atts(array('author' =&gt; 'admin', 'show' =&gt; 5, 'excerpt' =&gt; 'false'), $array));

 global $wpdb;
 $table = $wpdb-&gt;prefix . 'users';
 $result = $wpdb-&gt;get_results('SELECT ID FROM '.$table.' WHERE user_login = &quot;'.$author.'&quot;');
 $id = $result[0]-&gt;ID;
 $table = $wpdb-&gt;prefix . 'posts';
 $result = $wpdb-&gt;get_results('SELECT * FROM '.$table.' WHERE post_author = '.$id.' AND post_status = &quot;publish&quot; AND post_type = &quot;post&quot; ORDER BY post_date DESC');
 $i = 0;
 $html = '&lt;ul&gt;';
 foreach ($result as $numpost) {
 $html .= '&lt;li&gt;&lt;a href=&quot;'.get_permalink($numpost-&gt;ID).'&quot;&gt;'.$numpost-&gt;post_title.'&lt;/a&gt;';
 if($excerpt == 'true'){
 $html .= '&lt;p&gt;'.$numpost-&gt;post_excerpt.'&lt;/p&gt;';
 }
 $html .= '&lt;/li&gt;';
 $i++;
 if($i == $show){
 break;
 }
 }
 $html .= '&lt;/ul&gt;';

 return $html;
}

add_shortcode('latestbyauthor', 'latest_posts_by_author');

?&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://alexmansfield.com/plugins/latest-posts-by-author/feed</wfw:commentRss>
		<slash:comments>46</slash:comments>
		</item>
		<item>
		<title>Adding Custom WordPress Shortcodes</title>
		<link>http://alexmansfield.com/wordpress/adding-custom-wordpress-shortcodes</link>
		<comments>http://alexmansfield.com/wordpress/adding-custom-wordpress-shortcodes#comments</comments>
		<pubDate>Mon, 27 Jul 2009 19:45:56 +0000</pubDate>
		<dc:creator>alexmansfield</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://alexmansfield.com/?p=293</guid>
		<description><![CDATA[Introduced in WordPress 2.5, shortcodes make it easy to include pieces of code or content in multiple places across your site without having to repeatedly copy and paste. Also, if you need to go back and make adjustments, with shortcodes you don&#8217;t need to make the adjustment on every page, you just edit the shortcode [...]]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter size-full wp-image-305" title="shortcode" src="http://alexmansfield.com/wpress/wp-content/uploads/2009/07/shortcode.jpg" alt="shortcode" width="560" height="215" /></p>
<p>Introduced in WordPress 2.5, shortcodes make it easy to include pieces of code or content in multiple places across your site without having to repeatedly copy and paste. Also, if you need to go back and make adjustments, with shortcodes you don&#8217;t need to make the adjustment on every page, you just edit the shortcode source.</p>
<p>For example, just the other day I was creating an order form that had to appear on a number of different pages across the site I was working on. Each form was exactly the same with the exception of the item number. Since shortcodes can be made to accept arguments, I could call the shortcode and pass it the item number to use in the form (for those of you haven&#8217;t done any programming, arguments have nothing to do with arguing. Parameters or variables might be a more understandable words). Here&#8217;s how easy it was to include the form in a page:</p>
<pre class="brush: php; title: ; notranslate">[order item=&quot;59336&quot;]</pre>
<p>That tells WordPress to go get the code associated with [order] and set the item number to 59336. Now lets take a look at how to actually create the functionality I&#8217;ve been describing. It&#8217;s actually pretty simple.</p>
<p>Open up your functions.php file and scroll to the bottom. You&#8217;ll want to add your code just above the closing PHP tag (?&gt;). Here&#8217;s how you would add an order form similar to the one I described earlier. Keep in mind that an order form is just one of hundreds of uses for shortcodes. My purpose is to show you how to create shortcodes, not order forms, so I&#8217;m only going to explain the code that relates to the creation of the shortcode. Here&#8217;s the code:</p>
<pre class="brush: php; title: ; notranslate">function orderform($item_nbr) {
extract(shortcode_atts(array(&quot;item&quot; =&gt; '0'), $item_nbr));
return &lt;form method=&quot;post&quot;&gt;&lt;input name=&quot;item_number&quot; type=&quot;hidden&quot; value=&quot;' . $item . '&quot; /&gt;
&lt;label for=&quot;quantity&quot;&gt;Quantity:&lt;/label&gt;
&lt;input id=&quot;quantity&quot; name=&quot;quantity&quot; size=&quot;8&quot; type=&quot;text&quot; /&gt;
&lt;/div&gt;
&lt;div&gt;&lt;input id=&quot;submit&quot; type=&quot;submit&quot; value=&quot;Place Order&quot; /&gt;&lt;/div&gt;
&lt;/form&gt;';
}</pre>
<p>Take a look at the first line. It starts the function (function), gives it a name (orderform), and then assigns a name to the variable that holds the shortcode arguments ($item_nbr).</p>
<p>After that, you have to extract the actual value from the item_nbr variable to get the individual arguements. This is accomplished by line 2. The first part (array&#8230;) sets up the default values of the array while $item_nbr is the actual list of arguments being passed in by the shortcode.</p>
<p>Next you need to return the form as a string so that it can be displayed in the post. Notice this section of line 3:</p>
<pre class="brush: php; title: ; notranslate">' . $item . '</pre>
<p>This breaks out of the HTML string and inserts the item number that you passed in with the shortcode. Note that the variable name is &#8220;$item&#8221; which you set along with the default value when you extracted the array in line 2.</p>
<p>That&#8217;s it for the writing the function. Now you just need to let WordPress know about it. Just after the function, still in the functions.php file, add this line:</p>
<pre class="brush: php; title: ; notranslate">add_shortcode('order', 'orderform');</pre>
<p>The first argument (&#8216;order&#8217;) is the keyword for use in the shortcode. The second argument is the name of the function (&#8216;orderform&#8217;). So once again, all you have to do to include the form inside a post is use this short piece of code:</p>
<pre class="brush: php; title: ; notranslate">[order item=&quot;59336&quot;]</pre>
<p>Feel free to play around with the code and let me know if you have any questions.</p>
]]></content:encoded>
			<wfw:commentRss>http://alexmansfield.com/wordpress/adding-custom-wordpress-shortcodes/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

