<?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>Web Development and Design, Rochester NY</title>
	<atom:link href="http://ostedesign.com/feed" rel="self" type="application/rss+xml" />
	<link>http://ostedesign.com</link>
	<description>Oste Design</description>
	<lastBuildDate>Wed, 01 Feb 2012 15:29:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Using Ajax on Front End of WordPress Site</title>
		<link>http://ostedesign.com/using-ajax-on-front-end-of-wordpress-site</link>
		<comments>http://ostedesign.com/using-ajax-on-front-end-of-wordpress-site#comments</comments>
		<pubDate>Mon, 30 Jan 2012 20:20:16 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://ostedesign.com/?p=474</guid>
		<description><![CDATA[Using ajax in the admin of a WordPress site is easy because the variable ajaxurl is provided for you. This allows you to write the following code without issue. var data = { action: 'my_action', whatever: 1234 }; jQuery.post(ajaxurl, data, function(response) { alert('Got this from the server: ' + response); }); However, if you tried to use this same code on the front end of your site you will find that ajaxurl is undefined. The easy way around this might be to write your JavaScript code in a php file and use admin_url( &#8216;admin-ajax.php&#8217; ) like so echo "var data = { action: 'my_action', whatever: 1234 };"; echo "jQuery.post(".admin_url( 'admin-ajax.php' ).", data, function(response) { alert('Got this from the server: ' + response); });"; This approach is just plain ugly and nobody wants to write their JavaScript in a PHP file so I am here to show you a better way. When you enqueue your script you can also localize it using wp_localize_script, and that will allow you to make any variable accessible in your enqueued script. It looks like this. wp_enqueue_script( 'my_js', plugins_url('my-plugin/script.js'), array( 'jquery' ), '' ); wp_localize_script( 'my_js', 'my_ajax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) ); What [...]]]></description>
			<content:encoded><![CDATA[<p>Using ajax in the admin of a WordPress site is easy because the variable <code>ajaxurl</code> is provided for you. This allows you to write the following code without issue.</p>
<pre class="prettyprint">
var data = {
	action: 'my_action',
	whatever: 1234
};

jQuery.post(ajaxurl, data, function(response) {
	alert('Got this from the server: ' + response);
});
</pre>
<p>However, if you tried to use this same code on the front end of your site you will find that <code>ajaxurl</code> is <code>undefined</code>. The easy way around this <em>might</em> be to write your JavaScript code in a php file and use admin_url( &#8216;admin-ajax.php&#8217; ) like so</p>
<pre class="prettyprint">

echo "var data = {
	action: 'my_action',
	whatever: 1234
};";

echo "jQuery.post(".admin_url( 'admin-ajax.php' ).", data, function(response) {
	alert('Got this from the server: ' + response);
});";
</pre>
<p>This approach is just plain ugly and nobody wants to write their JavaScript in a PHP file so I am here to show you a better way. When you enqueue your script you can also localize it using <code>wp_localize_script</code>, and that will allow you to make any variable accessible in your enqueued script. It looks like this.</p>
<pre class="prettyprint">

wp_enqueue_script( 'my_js', plugins_url('my-plugin/script.js'), array( 'jquery' ), '' );
wp_localize_script( 'my_js', 'my_ajax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
</pre>
<p>What this does is it makes a new object called my_ajax and it populates it with a property called ajaxurl. This can be accessed by using <code>my_ajax.ajaxurl</code> inside your <code>script.js</code> file. Which will look something like this.</p>
<pre class="prettyprint">
var data = {
	action: 'my_action',
	whatever: 1234
};

jQuery.post(my_ajax.ajaxurl, data, function(response) {
	alert('Got this from the server: ' + response);
});
</pre>
<p>Notice how much this looks like the first snippet in this post? The only addition is our namespaced object <code>my_ajax</code>. That is more like it! The big idea here is to use wp_localize_script to make a variable accessible in our script.js file so we don&#8217;t have to code our JavaScript files in PHP (just writing that felt wrong, I can&#8217;t imagine actually doing it).</p>
<p>One more thing that should be noted. When you create your action you will need to hook on to the <code>wp_ajax_nopriv_*</code> action hook because <code>wp_ajax_*</code> will only fire for logged in users. So if you posted an action of my_action as we have done above you will hook onto the <code>wp_ajax_nopriv_my_action</code> hook.</p>
<p>Be sure to let me know if this was helpful or if you have any comments or questions below.</p>
]]></content:encoded>
			<wfw:commentRss>http://ostedesign.com/using-ajax-on-front-end-of-wordpress-site/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get Categories Even If They Are Not attached To A Post</title>
		<link>http://ostedesign.com/get-categories-even-if-they-are-not-attached-to-post</link>
		<comments>http://ostedesign.com/get-categories-even-if-they-are-not-attached-to-post#comments</comments>
		<pubDate>Tue, 24 Jan 2012 17:55:15 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://ostedesign.com/?p=467</guid>
		<description><![CDATA[WordPress has two helpful functions for getting categories/taxonomies, get_terms and get_categories. The latter uses get_terms inside the function so you can think of these two functions as basically being the same. With the main difference being that get_terms accepts two parameters with the first being the taxonomy name and the second being an array of arguments. While get_categories just accepts an array of arguments. The default return value for these functions is to return only categories that are linked to a post, but what if you want to get all terms even if they have not been attached to a post just yet? You can use hide_empty for just this situation, and it will look like this depending on which function you want to use. $terms = get_categories(array('hide_empty' => false)); or if you prefer get_terms $terms = get_terms( 'my_term', array('hide_empty' => false)); Be sure to check out the codex for more information on these two useful functions, but if you are simply trying to get all terms even if they are not assigned to a post this is your answer. Ask any questions or let me know if this was helpful in the comments below.]]></description>
			<content:encoded><![CDATA[<p>WordPress has two helpful functions for getting categories/taxonomies, <a href="http://codex.wordpress.org/Function_Reference/get_terms">get_terms</a> and <a href="http://codex.wordpress.org/Function_Reference/get_categories">get_categories</a>. The latter uses get_terms inside the function so you can think of these two functions as basically being the same. With the main difference being that get_terms accepts two parameters with the first being the taxonomy name and the second being an array of arguments. While get_categories just accepts an array of arguments.</p>
<p>The default return value for these functions is to return only categories that are linked to a post, but what if you want to get all terms even if they have not been attached to a post just yet?</p>
<p>You can use <code>hide_empty</code> for just this situation, and it will look like this depending on which function you want to use.</p>
<pre class="prettyprint">
$terms = get_categories(array('hide_empty' => false));
</pre>
<p>or if you prefer get_terms</p>
<pre class="prettyprint">
$terms = get_terms( 'my_term', array('hide_empty' => false));
</pre>
<p>Be sure to check out the codex for more information on these two useful functions, but if you are simply trying to get all terms even if they are not assigned to a post this is your answer. Ask any questions or let me know if this was helpful in the comments below.</p>
]]></content:encoded>
			<wfw:commentRss>http://ostedesign.com/get-categories-even-if-they-are-not-attached-to-post/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Register Activation Hook with Object Oriented Plugin</title>
		<link>http://ostedesign.com/register-activation-hook-with-object-oriented-plugin</link>
		<comments>http://ostedesign.com/register-activation-hook-with-object-oriented-plugin#comments</comments>
		<pubDate>Fri, 20 Jan 2012 22:01:03 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://ostedesign.com/?p=455</guid>
		<description><![CDATA[Recently I ran into an issue where I was not able to run activation code for a plugin I was creating. If you code your plugins in an object oriented fashion like me they usually start out something like this. class my_plugin{ function __construct() { //place actions and filters here like add_action('init', array($this, 'init')); } //place class methods for actions and filters here like function init(){ //do stuff on init } } //now we need to create an instance of my_plugin so our actions //and filters fire add_action('init', 'init', 1); function init(){ new my_plugin(); } The issue with all of this is is that we cannot easily register_activation_hook&#8216;s inside of our class, so my solution is to modify the code like so. Notice the new install() function and the register_activation_hook at the bottom of the page. Comments in read explain further. class my_plugin{ function __construct() { //place actoins and filters here like add_action('init', array($this, 'init')); } //place class methods for actions and filters here like function init(){ //do stuff on init } //this is the function that will fire when the plugin is activated function install(){ //you can include more files here //you can create more objects //you can do [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I ran into an issue where I was not able to run activation code for a plugin I was creating. If you code your plugins in an object oriented fashion like me they usually start out something like this.</p>
<pre class="prettyprint">
class my_plugin{

   function __construct() {
      //place actions and filters here like
      add_action('init', array($this, 'init'));
   }

   //place class methods for actions and filters here like
   function init(){
      //do stuff on init
   }

}

//now we need to create an instance of my_plugin so our actions
//and filters fire
add_action('init', 'init', 1);

function init(){
   new my_plugin();
}
</pre>
<p>The issue with all of this is is that we cannot easily <a href="http://codex.wordpress.org/Function_Reference/register_activation_hook">register_activation_hook</a>&#8216;s inside of our class, so my solution is to modify the code like so. Notice the new install() function and the register_activation_hook at the bottom of the page. Comments in read explain further.</p>
<pre class="prettyprint">
class my_plugin{

   function __construct() {
      //place actoins and filters here like
      add_action('init', array($this, 'init'));
   }

   //place class methods for actions and filters here like
   function init(){
      //do stuff on init
   }

   //this is the function that will fire when the plugin is activated
   function install(){
       //you can include more files here
       //you can create more objects
       //you can do anything you might need to do on activation here!
    }

}

//now we need to create an instance of my_plugin so our actions and filters fire
add_action('init', 'init', 1);

function init(){
   new my_plugin();
}

//this tells WordPress to fire the install method of the
//my_plugin class whenever the plugin is activated
//the install function is in the class code above
register_activation_hook( __FILE__, array('my_plugin', 'install') );
</pre>
<p>This is my preferred way for registering activation hooks. Let me know if you have any questions or if this was helpful in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://ostedesign.com/register-activation-hook-with-object-oriented-plugin/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Search Files For Text On Mac</title>
		<link>http://ostedesign.com/search-files-for-text-on-mac</link>
		<comments>http://ostedesign.com/search-files-for-text-on-mac#comments</comments>
		<pubDate>Thu, 19 Jan 2012 00:16:33 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mac]]></category>

		<guid isPermaLink="false">http://ostedesign.com/?p=442</guid>
		<description><![CDATA[The command line is a very valuable tool, and one of its most valuable commands is the grep command. This command allows you to search within files for a text string. You can use it like the following to search files within your current directory. grep -l "Find Me" * or like the below command in order to search recursively(r) within all folders up the tree from your current directory. So if you are in the root directory the following command will search for every file on your hard drive. grep -lr "Find Me" * You can also search within specific file extensions by changing the * to something like *.html or *.php. Now that is helpful.]]></description>
			<content:encoded><![CDATA[<p>The command line is a very valuable tool, and one of its most valuable commands is the <code>grep</code> command. This command allows you to search within files for a text string.</p>
<p>You can use it like the following to search files within your current directory.</p>
<pre class="prettyprint">
grep -l "Find Me" *
</pre>
<p>or like the below command in order to search recursively(r) within all folders up the tree from your current directory. So if you are in the root directory the following command will search for <strong>every</strong> file on your hard drive.</p>
<pre class="prettyprint">
grep -lr "Find Me" *
</pre>
<p>You can also search within specific file extensions by changing the * to something like *.html or *.php.</p>
<p>Now that is helpful.</p>
]]></content:encoded>
			<wfw:commentRss>http://ostedesign.com/search-files-for-text-on-mac/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Content Precedes Design</title>
		<link>http://ostedesign.com/content-precedes-design</link>
		<comments>http://ostedesign.com/content-precedes-design#comments</comments>
		<pubDate>Mon, 09 Jan 2012 20:30:47 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[web design]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://ostedesign.com/?p=352</guid>
		<description><![CDATA[I ran across a great quote from a well respected member of the web development and design community the other day and I wanted to share it here. The quote comes from Jeffrey Zeldman and it provides some valuable insight on how content should be approached when creating a design. &#8220;Content precedes design. Design in the absence of content is not design, it&#8217;s decoration.&#8221; I like this quote because it emphasis the fact that the web starts with content and that our designs should cater to this content. Not the other way around. Don&#8217;t get me wrong, I love illustrations and graphics, but I think the web is a place for content and we should build our websites around that content. Preferably with a crystal clean responsive design]]></description>
			<content:encoded><![CDATA[<p>I ran across a great quote from a well respected member of the web development and design community the other day and I wanted to share it here. The quote comes from <a href="http://www.zeldman.com/about/">Jeffrey Zeldman</a> and it provides some valuable insight on how content should be approached when creating a design.</p>
<blockquote><p>&#8220;Content precedes design. Design in the absence of content is not design, it&#8217;s decoration.&#8221;</p></blockquote>
<p>I like this quote because it emphasis the fact that the web starts with content and that our designs should cater to this content. Not the other way around. Don&#8217;t get me wrong, I love illustrations and graphics, but I think the web is a place for content and we should build our websites around that content. Preferably with a crystal clean responsive design <img src='http://ostedesign.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://ostedesign.com/content-precedes-design/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>3 Key Design Principles of the &#8220;New&#8221; Google Experience</title>
		<link>http://ostedesign.com/3-key-design-principles-of-the-new-google-experience</link>
		<comments>http://ostedesign.com/3-key-design-principles-of-the-new-google-experience#comments</comments>
		<pubDate>Fri, 06 Jan 2012 18:02:39 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[web design]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://ostedesign.com/?p=414</guid>
		<description><![CDATA[If you haven&#8217;t noticed already Google has created a new experience for many of their products like Gmail, Docs and Calendar. I was doing some reading on Google&#8217;s support pages and I came across an interesting list. It is a list of the three key design principles that Google is focusing on: Focus: With the design changes in the coming weeks and months, we’re bringing forward the stuff that matters to you and getting all the other clutter out of your way. Elasticity: The new design will soon allow you to seamlessly transition from your desktop computer to your mobile phone to your tablet, while keeping a consistent visual experience. We aim to bring you this flexibility without sacrificing style or usefulness. Effortlessness: Our design philosophy is to combine power with simplicity. We want to keep our look simple and clean. But behind the seemingly simple design, the changes use new technologies to make sure you have all the power of the web behind you. In my opinion these are three great design principles. I love simpleness and I like the fact that Google is working to make their products even more simple and user friendly. Making these products responsive [...]]]></description>
			<content:encoded><![CDATA[<p>If you haven&#8217;t noticed already Google has created a new experience for many of their products like Gmail, Docs and Calendar. I was doing some reading on Google&#8217;s support pages and I came across an interesting list. It is a list of the three key design principles that Google is focusing on: </p>
<ul>
<li>Focus: With the design changes in the coming weeks and months, we’re bringing forward the stuff that matters to you and getting all the other clutter out of your way.</li>
<li>Elasticity: The new design will soon allow you to seamlessly transition from your desktop computer to your mobile phone to your tablet, while keeping a consistent visual experience. We aim to bring you this flexibility without sacrificing style or usefulness.</li>
<li>Effortlessness: Our design philosophy is to combine power with simplicity. We want to keep our look simple and clean. But behind the seemingly simple design, the changes use new technologies to make sure you have all the power of the web behind you.</li>
</ul>
<p>In my opinion these are three great design principles. I love simpleness and I like the fact that Google is working to make their products even more simple and user friendly. Making these products responsive is great too, and this marks a big step in Google&#8217;s effort to bring the mobile experience to the cloud. Could this one day make Android devices the clear cut winner of the mobile OS battle?</p>
]]></content:encoded>
			<wfw:commentRss>http://ostedesign.com/3-key-design-principles-of-the-new-google-experience/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Awesome CSS3 Gradient Tool</title>
		<link>http://ostedesign.com/awesome-css3-gradient-tool</link>
		<comments>http://ostedesign.com/awesome-css3-gradient-tool#comments</comments>
		<pubDate>Thu, 05 Jan 2012 15:40:19 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[web design]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://ostedesign.com/?p=409</guid>
		<description><![CDATA[I found that creating a CSS gradient that is cross browser compliant to be a major chore. That is until I stumbled upon Colorzilla&#8217;s CSS gradient tool, found here. They have created a tool makes creating gradients as intuitive and user friendly as Photoshop. After testing out a few other tools on the interwebs I am giving Colorzilla&#8217;s CSS gradient tool my full endorsement, and I recommend that you try it out next time you need a gradient on your web page. They also make a great Firefox addon that lets you turn any web page into a color picker palette, you can check that out here.]]></description>
			<content:encoded><![CDATA[<p>I found that creating a CSS gradient that is cross browser compliant to be a major chore. That is until I stumbled upon Colorzilla&#8217;s CSS gradient tool, found <a title="css3 gradient tool" href="http://www.colorzilla.com/gradient-editor/">here</a>. They have created a tool makes creating gradients as intuitive and user friendly as Photoshop. After testing out a few other tools on the interwebs I am giving Colorzilla&#8217;s CSS gradient tool my full endorsement, and I recommend that you try it out next time you need a gradient on your web page. They also make a great Firefox addon that lets you turn any web page into a color picker palette, you can check that out <a href="https://addons.mozilla.org/en-US/firefox/addon/colorzilla/" title="colorzilla color picker">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ostedesign.com/awesome-css3-gradient-tool/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Awesome Resource for Creating Drop Down Menus</title>
		<link>http://ostedesign.com/awesome-resource-for-creating-drop-down-menus</link>
		<comments>http://ostedesign.com/awesome-resource-for-creating-drop-down-menus#comments</comments>
		<pubDate>Thu, 29 Dec 2011 17:29:15 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[web design]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://ostedesign.com/?p=397</guid>
		<description><![CDATA[I recently needed to redesign a drop down navigation menu that was less than user friendly. I came across an article on Smashing Magazine that covers all of the bases for this type of work. It provided some great inspiration and talked about ways to improve usability. If you are interested in the article check it out below. Designing Drop Down Menus I will post the result of our newly redesigned navigation menu in the near future]]></description>
			<content:encoded><![CDATA[<p>I recently needed to redesign a drop down navigation menu that was less than user friendly. I came across an article on Smashing Magazine that covers all of the bases for this type of work. It provided some great inspiration and talked about ways to improve usability. If you are interested in the article check it out below.</p>
<p><a href="http://www.smashingmagazine.com/2009/03/24/designing-drop-down-menus-examples-and-best-practices/">Designing Drop Down Menus</a></p>
<p>I will post the result of our newly redesigned navigation menu in the near future</p>
]]></content:encoded>
			<wfw:commentRss>http://ostedesign.com/awesome-resource-for-creating-drop-down-menus/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Automatically Change Post Slug and Permalink When Editing WordPress Title</title>
		<link>http://ostedesign.com/automatically-change-post-slug-and-permalink-when-editing-wordpress-title</link>
		<comments>http://ostedesign.com/automatically-change-post-slug-and-permalink-when-editing-wordpress-title#comments</comments>
		<pubDate>Wed, 28 Dec 2011 17:33:42 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://ostedesign.com/?p=389</guid>
		<description><![CDATA[If you want to automatically change your post slug which will ultimately change your permalink when you change the title of your post, paste the following code in your functions.php file. //add our action add_action( 'save_post', 'my_save_post', 11, 2 ); function my_save_post($post_id, $post){ //if it is just a revision don't worry about it if (wp_is_post_revision($post_id)) return false; //if the post is an auto-draft we don't want to do anything either if($post->post_status != 'auto-draft' ){ // unhook this function so it doesn't loop infinitely remove_action('save_post', 'my_save_post' ); //this is where it happens -- update the post and change the post_name/slug to the post_title wp_update_post(array('ID' => $post_id, 'post_name' => str_replace(' ', '-', $_POST['post_title']))); //re-hook this function add_action('save_post', 'my_save_post' ); } } The following line of code is the key to this code. It tells WordPress that when a post is updated to take the new post title and use that for the post name/ permalink. wp_update_post(array('ID' => $post_id, 'post_name' => str_replace(' ', '-', $_POST['post_title']))); The comments in red should help explain the rest of what is happening. Let me know if this was useful for you in the comments, or if you have any questions.]]></description>
			<content:encoded><![CDATA[<p>If you want to automatically change your post slug which will ultimately change your permalink when you change the title of your post, paste the following code in your functions.php file.</p>
<pre class="prettyprint">

//add our action
add_action( 'save_post', 'my_save_post', 11, 2 );

function my_save_post($post_id, $post){

   //if it is just a revision don't worry about it
   if (wp_is_post_revision($post_id))
      return false;

   //if the post is an auto-draft we don't want to do anything either
   if($post->post_status != 'auto-draft' ){

       // unhook this function so it doesn't loop infinitely
       remove_action('save_post', 'my_save_post' );

      //this is where it happens -- update the post and change the post_name/slug to the post_title
      wp_update_post(array('ID' => $post_id, 'post_name' => str_replace(' ', '-', $_POST['post_title'])));

      //re-hook this function
      add_action('save_post', 'my_save_post' );
   }
}
</pre>
<p>The following line of code is the key to this code. It tells WordPress that when a post is updated to take the new post title and use that for the post name/ permalink.</p>
<pre class="prettyprint">
wp_update_post(array('ID' => $post_id, 'post_name' => str_replace(' ', '-', $_POST['post_title'])));
</pre>
<p>The comments in red should help explain the rest of what is happening. Let me know if this was useful for you in the comments, or if you have any questions.</p>
]]></content:encoded>
			<wfw:commentRss>http://ostedesign.com/automatically-change-post-slug-and-permalink-when-editing-wordpress-title/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Starting Point for Custom WordPress Registration Form</title>
		<link>http://ostedesign.com/starting-point-for-custom-wordpress-registration-form</link>
		<comments>http://ostedesign.com/starting-point-for-custom-wordpress-registration-form#comments</comments>
		<pubDate>Tue, 27 Dec 2011 21:09:37 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://ostedesign.com/?p=356</guid>
		<description><![CDATA[Recently I had a need for a custom registration form in WordPress. The page needed to look like the rest of the site, and it needed to allow the user to set their password. Here is what I came up with. Place the code in the appropriate theme file and you should be all set. Read comments in red for further explanation of the code. If you have any questions please ask them in the comments below. Adding more fields and possibly a captcha along with some client side validation could make this registration form complete. Maybe an idea for a WordPress plugin someday? &#60;?php //if the form is posted we need to validate if ('POST' == $_SERVER['REQUEST_METHOD']) { //assign post values to variables $user_login = $_POST['user_login']; $user_email = $_POST['user_email']; $user_pass = $_POST['user_pass']; $user_pass_confirm = $_POST['user_pass_confirm']; //initialize a WP_Errror object $errors = new WP_Error(); //username is required if ( isset($user_login) &#38;&#38; $user_login == '' ) $errors-&#62;add('login_required', __('The username field is required.')); //email is required if ( isset($user_email) &#38;&#38; $user_email == '' ) $errors-&#62;add('email_required', __('The email field is required.')); //email needs to be a valid email if ( isset($user_email) &#38;&#38; !is_email($user_email) ) $errors-&#62;add('email_invalid', __('The email is not valid.')); //passwords must match [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I had a need for a custom registration form in WordPress. The page needed to look like the rest of the site, and it needed to allow the user to set their password.</p>
<p>Here is what I came up with. Place the code in the appropriate theme file and you should be all set. Read comments in red for further explanation of the code. If you have any questions please ask them in the comments below.</p>
<p>Adding more fields and possibly a captcha along with some client side validation could make this registration form complete. Maybe an idea for a WordPress plugin someday?</p>
<pre class="prettyprint">
<code>
&lt;?php
//if the form is posted we need to validate
if ('POST' == $_SERVER['REQUEST_METHOD']) {
   //assign post values to variables
   $user_login = $_POST['user_login'];
   $user_email = $_POST['user_email'];
   $user_pass  = $_POST['user_pass'];
   $user_pass_confirm = $_POST['user_pass_confirm'];
   //initialize a WP_Errror object
   $errors = new WP_Error();
   //username is required
   if (  isset($user_login) &amp;&amp; $user_login == '' )
      $errors-&gt;add('login_required', __('The username field is required.'));
   //email is required
   if (  isset($user_email) &amp;&amp; $user_email == '' )
      $errors-&gt;add('email_required', __('The email field is required.'));
   //email needs to be a valid email
   if (  isset($user_email) &amp;&amp; !is_email($user_email) )
      $errors-&gt;add('email_invalid', __('The email is not valid.'));
   //passwords must match
   if ( ($user_pass != '' &amp;&amp; $user_pass_confirm != '') &amp;&amp; $user_pass != $user_pass_confirm )
      $errors-&gt;add('password_mismatch', __('The passwords do not match.'));
   //password is required
   if (  isset($user_pass) &amp;&amp; $user_pass == '' )
       $errors-&gt;add('password_required', __('The password is required.'));
   //confirm password is required
   if (  isset($user_pass_confirm) &amp;&amp; $user_pass_confirm == '' )
      $errors-&gt;add('password_confirm_required', __('The confirm password field is required.'));
   //if we don't have any errors lets try to insert the user
   if(!$errors-&gt;get_error_codes())
       $errors = $user_id = wp_insert_user(array('user_login' =&gt; $user_login, 'user_email' =&gt; $user_email, 'user_pass' =&gt; $user_pass));
   //if we still do not have any errors it was a success
   if (!is_wp_error($errors)) {
      echo '&lt;p&gt;Success&lt;/p&gt;';
   }else{//output the errors
      foreach($errors-&gt;errors as $code =&gt; $error)
         echo '&lt;p&gt;'.$error[0].'&lt;/p&gt;';
   }
}

?&gt;

&lt;!--the form--&gt;
&lt;form name="registerform" id="registerform" action="&lt;?php echo the_permalink(); ?&gt;" method="post"&gt;

&lt;p&gt;
&lt;label for="user_login"&gt;&lt;?php _e('Username') ?&gt;&lt;br /&gt;
&lt;input type="text" name="user_login" id="user_login" class="input" value="&lt;?php echo esc_attr(stripslashes($user_login)); ?&gt;" tabindex="1" /&gt;&lt;/label&gt;
&lt;/p&gt;

&lt;p&gt;
&lt;label for="user_email"&gt;&lt;?php _e('E-mail') ?&gt;&lt;br /&gt;
&lt;input type="text" name="user_email" id="user_email" class="input" value="&lt;?php echo esc_attr(stripslashes($user_email)); ?&gt;" tabindex="2" /&gt;&lt;/label&gt;
&lt;/p&gt;

&lt;p&gt;
&lt;label for="user_pass"&gt;&lt;?php _e('Password') ?&gt;&lt;br /&gt;
&lt;input type="password" name="user_pass" id="user_pass" class="input" value="" tabindex="3" /&gt;&lt;/label&gt;
&lt;/p&gt;

&lt;p&gt;
&lt;label for="user_pass_confirm"&gt;&lt;?php _e('Confirm Password') ?&gt;&lt;br /&gt;
&lt;input type="password" name="user_pass_confirm" id="user_pass_confirm" class="input" value="" tabindex="4" /&gt;&lt;/label&gt;
&lt;/p&gt;

&lt;?php do_action('register_form'); ?&gt;

&lt;p class="submit"&gt;
&lt;input type="submit" name="wp-submit" id="wp-submit" class="button-primary" value="&lt;?php esc_attr_e('Register'); ?&gt;" tabindex="100" /&gt;
&lt;/p&gt;

&lt;/form&gt;
</code>
</pre>
<p>Let me know if this was useful for you in the comments, or if you have any questions.</p>
]]></content:encoded>
			<wfw:commentRss>http://ostedesign.com/starting-point-for-custom-wordpress-registration-form/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

