<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Custom URL rewrites in WordPress &#8211; A Getting Started Guide</title>
	<atom:link href="http://matty.co.za/2009/11/custom-url-rewrites-in-wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://matty.co.za/2009/11/custom-url-rewrites-in-wordpress/</link>
	<description>Web developer, WordPress enthusiast, avid musician and blogger</description>
	<lastBuildDate>Thu, 10 May 2012 07:37:42 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: Matty</title>
		<link>http://matty.co.za/2009/11/custom-url-rewrites-in-wordpress/comment-page-1/#comment-3705</link>
		<dc:creator>Matty</dc:creator>
		<pubDate>Sat, 24 Sep 2011 07:29:06 +0000</pubDate>
		<guid isPermaLink="false">http://matty.co.za/?p=701#comment-3705</guid>
		<description>Hi AFAN,

No problem. Let me see if I can assist. :)

Regarding your &quot;cars&quot; example, I&#039;d advise using the &quot;register_post_type()&quot; function and creating a custom &quot;cars&quot; post type. This will provide the URL structure you&#039;re looking for, along with a templating structure in the form of the &quot;single.php&quot; file or, for more specific customisations, the &quot;single-car.php&quot; file. You&#039;ll then have access to the appropriate ID when viewing that &quot;car&quot;.

More information on this can be found at: http://codex.wordpress.org/Function_Reference/register_post_type

Regarding your &quot;profile&quot; example, I&#039;d recommend using the built in WordPress authors system. Each profile is a username on your website, with a URL that follows the convention of http://domain.com/author/username/. The output of this screen can be customised via the &quot;author.php&quot; template file.

Therefore, in the examples you&#039;ve posted above, the desired results can be achieved without a custom WordPress URL rewrite rule. :)

I hope this clarifies things. :)

Cheers,
Matty.</description>
		<content:encoded><![CDATA[<p>Hi AFAN,</p>
<p>No problem. Let me see if I can assist. <img src='http://matty.co.za/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Regarding your &#8220;cars&#8221; example, I&#8217;d advise using the &#8220;register_post_type()&#8221; function and creating a custom &#8220;cars&#8221; post type. This will provide the URL structure you&#8217;re looking for, along with a templating structure in the form of the &#8220;single.php&#8221; file or, for more specific customisations, the &#8220;single-car.php&#8221; file. You&#8217;ll then have access to the appropriate ID when viewing that &#8220;car&#8221;.</p>
<p>More information on this can be found at: <a href="http://codex.wordpress.org/Function_Reference/register_post_type" rel="nofollow">http://codex.wordpress.org/Function_Reference/register_post_type</a></p>
<p>Regarding your &#8220;profile&#8221; example, I&#8217;d recommend using the built in WordPress authors system. Each profile is a username on your website, with a URL that follows the convention of <a href="http://domain.com/author/username/" rel="nofollow">http://domain.com/author/username/</a>. The output of this screen can be customised via the &#8220;author.php&#8221; template file.</p>
<p>Therefore, in the examples you&#8217;ve posted above, the desired results can be achieved without a custom WordPress URL rewrite rule. <img src='http://matty.co.za/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I hope this clarifies things. <img src='http://matty.co.za/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Cheers,<br />
Matty.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: AFAN</title>
		<link>http://matty.co.za/2009/11/custom-url-rewrites-in-wordpress/comment-page-1/#comment-3704</link>
		<dc:creator>AFAN</dc:creator>
		<pubDate>Sat, 24 Sep 2011 05:18:51 +0000</pubDate>
		<guid isPermaLink="false">http://matty.co.za/?p=701#comment-3704</guid>
		<description>HI Matty!

OK.. I have spent a dozen hours on this and believe your article to be the closest thing to what I want to accomplish. I always try to find the solution myself, but as you started out by saying... others seem to LEAVE OUT exactly what you need.

So looking at your code I am hoping there is something you might do to help.
First you should know permalinks are working just fine for me in my WP site.
I totally get all aspects about the built in WP permalink stuff - and its&#039; all good.

But here&#039;s the deal. And I will be as clear as I can.
I am looking to create a custom rewrite(s) - which is how I came to land on your page.

I have created a template_profile.php for my theme, and certain things on this page will change based on the value  of ?id=XX . So for example, if I hit my page at http://mydomain.com/profile/?id=12 ... it will go into a folder named &#039;12&#039; and pull out a picture from that folder. 

or as another example:
http://mydomain.com/cars/?vin=123456

I already have this working exactly as I want.
BUT! the &#039;id&#039; variable in my dream scenario is a username.

So I want the link to look like this:
http://mydomain.com/profile/username

....or....

http://mydomain.com/cars/123456


Side Note: Ideally I would like http://mydomain.com/username but I&#039;m guessing if some bozo&#039;s username is &quot;contact&quot; it would conflict with my contact page - which already exists. So http://mydomain.com/profile/username is totally fine with me.

I can&#039;t seem to get my head around how to do this and make the url look nice.

The big challenge is to pass the (registered) username into the pretty url, get the user_id number from that, and then go into that numbered folder to pull some content out of that folder - to populate the page.

But HOW do I get that number from a /profile/username if the url doesn&#039;t exist yet????? Mod rewrite should be the answer, yes???

I hope this is all clear. And a thousand thanks for any info you can provide. I think the solution might be staring me in the face right here on your page! But I don&#039;t quite get it yet. And Googling this has been difficult because I am not even sure  what to google specific to my scenario.

Anyway . Thanks again.</description>
		<content:encoded><![CDATA[<p>HI Matty!</p>
<p>OK.. I have spent a dozen hours on this and believe your article to be the closest thing to what I want to accomplish. I always try to find the solution myself, but as you started out by saying&#8230; others seem to LEAVE OUT exactly what you need.</p>
<p>So looking at your code I am hoping there is something you might do to help.<br />
First you should know permalinks are working just fine for me in my WP site.<br />
I totally get all aspects about the built in WP permalink stuff &#8211; and its&#8217; all good.</p>
<p>But here&#8217;s the deal. And I will be as clear as I can.<br />
I am looking to create a custom rewrite(s) &#8211; which is how I came to land on your page.</p>
<p>I have created a template_profile.php for my theme, and certain things on this page will change based on the value  of ?id=XX . So for example, if I hit my page at <a href="http://mydomain.com/profile/?id=12" rel="nofollow">http://mydomain.com/profile/?id=12</a> &#8230; it will go into a folder named &#8217;12&#8242; and pull out a picture from that folder. </p>
<p>or as another example:<br />
<a href="http://mydomain.com/cars/?vin=123456" rel="nofollow">http://mydomain.com/cars/?vin=123456</a></p>
<p>I already have this working exactly as I want.<br />
BUT! the &#8216;id&#8217; variable in my dream scenario is a username.</p>
<p>So I want the link to look like this:<br />
<a href="http://mydomain.com/profile/username" rel="nofollow">http://mydomain.com/profile/username</a></p>
<p>&#8230;.or&#8230;.</p>
<p><a href="http://mydomain.com/cars/123456" rel="nofollow">http://mydomain.com/cars/123456</a></p>
<p>Side Note: Ideally I would like <a href="http://mydomain.com/username" rel="nofollow">http://mydomain.com/username</a> but I&#8217;m guessing if some bozo&#8217;s username is &#8220;contact&#8221; it would conflict with my contact page &#8211; which already exists. So <a href="http://mydomain.com/profile/username" rel="nofollow">http://mydomain.com/profile/username</a> is totally fine with me.</p>
<p>I can&#8217;t seem to get my head around how to do this and make the url look nice.</p>
<p>The big challenge is to pass the (registered) username into the pretty url, get the user_id number from that, and then go into that numbered folder to pull some content out of that folder &#8211; to populate the page.</p>
<p>But HOW do I get that number from a /profile/username if the url doesn&#8217;t exist yet????? Mod rewrite should be the answer, yes???</p>
<p>I hope this is all clear. And a thousand thanks for any info you can provide. I think the solution might be staring me in the face right here on your page! But I don&#8217;t quite get it yet. And Googling this has been difficult because I am not even sure  what to google specific to my scenario.</p>
<p>Anyway . Thanks again.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matty</title>
		<link>http://matty.co.za/2009/11/custom-url-rewrites-in-wordpress/comment-page-1/#comment-3700</link>
		<dc:creator>Matty</dc:creator>
		<pubDate>Tue, 09 Aug 2011 07:17:40 +0000</pubDate>
		<guid isPermaLink="false">http://matty.co.za/?p=701#comment-3700</guid>
		<description>Hi Ste,

Without seeing the actual code in question, it can be difficult to ascertain the exact cause of the issue.

I&#039;d recommend using a custom post type to handle the vehicle listings, which would take care of the permalinks and custom rewrite rules for you. More on this can be found &lt;a href=&quot;http://codex.wordpress.org/Function_Reference/register_post_type&quot; rel=&quot;nofollow&quot;&gt;here on the WordPress Codex&lt;/a&gt;. :)

Cheers,
Matty.</description>
		<content:encoded><![CDATA[<p>Hi Ste,</p>
<p>Without seeing the actual code in question, it can be difficult to ascertain the exact cause of the issue.</p>
<p>I&#8217;d recommend using a custom post type to handle the vehicle listings, which would take care of the permalinks and custom rewrite rules for you. More on this can be found <a href="http://codex.wordpress.org/Function_Reference/register_post_type" rel="nofollow">here on the WordPress Codex</a>. <img src='http://matty.co.za/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Cheers,<br />
Matty.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ste Wright</title>
		<link>http://matty.co.za/2009/11/custom-url-rewrites-in-wordpress/comment-page-1/#comment-3699</link>
		<dc:creator>Ste Wright</dc:creator>
		<pubDate>Tue, 09 Aug 2011 07:06:38 +0000</pubDate>
		<guid isPermaLink="false">http://matty.co.za/?p=701#comment-3699</guid>
		<description>Hi Bud

I&#039;m having the same problem too. I&#039;m trying to use this tutorial to eliminate ugly vehicle id&#039;s from our web site, i.e.:

http://www.colwynbaymotorcycles.com/honda/new-honda-bike-stock/view-honda-bike/?v_id=34

and changing it to something like this:

http://www.colwynbaymotorcycles.com/honda/new-honda-bike-stock/view-honda-bike/v_id/34 or even just .../view-honda-bike/34

Problem I just can&#039;t get this to work. My permalink structure is:

/%year%/%monthnum%/%postname%/

What am I doing wrong?

Thanks in advance!</description>
		<content:encoded><![CDATA[<p>Hi Bud</p>
<p>I&#8217;m having the same problem too. I&#8217;m trying to use this tutorial to eliminate ugly vehicle id&#8217;s from our web site, i.e.:</p>
<p><a href="http://www.colwynbaymotorcycles.com/honda/new-honda-bike-stock/view-honda-bike/?v_id=34" rel="nofollow">http://www.colwynbaymotorcycles.com/honda/new-honda-bike-stock/view-honda-bike/?v_id=34</a></p>
<p>and changing it to something like this:</p>
<p><a href="http://www.colwynbaymotorcycles.com/honda/new-honda-bike-stock/view-honda-bike/v_id/34" rel="nofollow">http://www.colwynbaymotorcycles.com/honda/new-honda-bike-stock/view-honda-bike/v_id/34</a> or even just &#8230;/view-honda-bike/34</p>
<p>Problem I just can&#8217;t get this to work. My permalink structure is:</p>
<p>/%year%/%monthnum%/%postname%/</p>
<p>What am I doing wrong?</p>
<p>Thanks in advance!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matty</title>
		<link>http://matty.co.za/2009/11/custom-url-rewrites-in-wordpress/comment-page-1/#comment-3661</link>
		<dc:creator>Matty</dc:creator>
		<pubDate>Fri, 15 Apr 2011 19:36:01 +0000</pubDate>
		<guid isPermaLink="false">http://matty.co.za/?p=701#comment-3661</guid>
		<description>Hi Mick,

Thanks for your kind words about my tutorial. I&#039;m glad you&#039;ve found it to be useful. :)

/%postname%/ is causing a conflict with the default rewrite rule, causing it to not know where to turn, effectively. If you&#039;d like to use /%postname%/ (not recommended, as it puts extra load on the system), I&#039;d recommend placing it as a &quot;custom structure&quot; under &quot;Settings -&gt; Permalinks&quot; in your WordPress Admin. :)

Cheers,
Matty.</description>
		<content:encoded><![CDATA[<p>Hi Mick,</p>
<p>Thanks for your kind words about my tutorial. I&#8217;m glad you&#8217;ve found it to be useful. <img src='http://matty.co.za/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>/%postname%/ is causing a conflict with the default rewrite rule, causing it to not know where to turn, effectively. If you&#8217;d like to use /%postname%/ (not recommended, as it puts extra load on the system), I&#8217;d recommend placing it as a &#8220;custom structure&#8221; under &#8220;Settings -&gt; Permalinks&#8221; in your WordPress Admin. <img src='http://matty.co.za/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Cheers,<br />
Matty.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MickP</title>
		<link>http://matty.co.za/2009/11/custom-url-rewrites-in-wordpress/comment-page-1/#comment-3660</link>
		<dc:creator>MickP</dc:creator>
		<pubDate>Thu, 14 Apr 2011 16:33:56 +0000</pubDate>
		<guid isPermaLink="false">http://matty.co.za/?p=701#comment-3660</guid>
		<description>This was very very useful. I got all my rewrites working nicely, using a single general pagename rule, e.g

$rewrite_keywords_structure = $wp_rewrite-&gt;root . &quot;%pagename%/$rewrite_tag/&quot;;

However... my regular permalink&#039;d blog posts don&#039;t work anymore. i.e. 
http://example.com/2011/03/hello-world/
now gives a 404.

Any ideas? Having flushed the Wordpress default rules, do I have to explicitly put appropriate default ones back in?

Cheers
Mick</description>
		<content:encoded><![CDATA[<p>This was very very useful. I got all my rewrites working nicely, using a single general pagename rule, e.g</p>
<p>$rewrite_keywords_structure = $wp_rewrite-&gt;root . &#8220;%pagename%/$rewrite_tag/&#8221;;</p>
<p>However&#8230; my regular permalink&#8217;d blog posts don&#8217;t work anymore. i.e.<br />
<a href="http://example.com/2011/03/hello-world/" rel="nofollow">http://example.com/2011/03/hello-world/</a><br />
now gives a 404.</p>
<p>Any ideas? Having flushed the WordPress default rules, do I have to explicitly put appropriate default ones back in?</p>
<p>Cheers<br />
Mick</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matty</title>
		<link>http://matty.co.za/2009/11/custom-url-rewrites-in-wordpress/comment-page-1/#comment-3438</link>
		<dc:creator>Matty</dc:creator>
		<pubDate>Sun, 24 Jan 2010 09:36:10 +0000</pubDate>
		<guid isPermaLink="false">http://matty.co.za/?p=701#comment-3438</guid>
		<description>@Dan Thanks for your comment, Dan. :)

I don&#039;t think using `init` or `admin-init` makes much of a difference. It means it&#039;ll either run on init only when in the admin area or on init in general. Either way, init happens and the function doesn&#039;t seem very intensive. Using `admin-init` could possibly increase front-end performance though, as the function would not be running on the front-end. Not sure if the performance difference would be noticeable though.

It looks, to me, like it&#039;s a case of 6 of 1 or half a dozen of the other. Using either method, the function will run at the init stage. :)

Thanks for the link and quote. I find the Wordpress codex to be a useful resource which I use regularly. :)

Cheers,
Matt.</description>
		<content:encoded><![CDATA[<p>@Dan Thanks for your comment, Dan. <img src='http://matty.co.za/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I don&#8217;t think using `init` or `admin-init` makes much of a difference. It means it&#8217;ll either run on init only when in the admin area or on init in general. Either way, init happens and the function doesn&#8217;t seem very intensive. Using `admin-init` could possibly increase front-end performance though, as the function would not be running on the front-end. Not sure if the performance difference would be noticeable though.</p>
<p>It looks, to me, like it&#8217;s a case of 6 of 1 or half a dozen of the other. Using either method, the function will run at the init stage. <img src='http://matty.co.za/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Thanks for the link and quote. I find the WordPress codex to be a useful resource which I use regularly. <img src='http://matty.co.za/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Cheers,<br />
Matt.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan Smart</title>
		<link>http://matty.co.za/2009/11/custom-url-rewrites-in-wordpress/comment-page-1/#comment-3437</link>
		<dc:creator>Dan Smart</dc:creator>
		<pubDate>Mon, 18 Jan 2010 17:25:03 +0000</pubDate>
		<guid isPermaLink="false">http://matty.co.za/?p=701#comment-3437</guid>
		<description>The guidance given in the Wordpress Codex is to do it in &#039;init&#039; rather than admin-init&#039;, however I may be not taking into account performance with this.

From: http://codex.wordpress.org/Query_Overview:

&quot;So if you want to modify rewrite rules, you will need to call $wp_rewrite-&gt;flush_rules() to force them to recalculate. You&#039;ll need to do this in your plugin&#039;s init action, so that it happens early enough in the process. &quot;

Cheers...Dan</description>
		<content:encoded><![CDATA[<p>The guidance given in the WordPress Codex is to do it in &#8216;init&#8217; rather than admin-init&#8217;, however I may be not taking into account performance with this.</p>
<p>From: <a href="http://codex.wordpress.org/Query_Overview" rel="nofollow">http://codex.wordpress.org/Query_Overview</a>:</p>
<p>&#8220;So if you want to modify rewrite rules, you will need to call $wp_rewrite-&gt;flush_rules() to force them to recalculate. You&#8217;ll need to do this in your plugin&#8217;s init action, so that it happens early enough in the process. &#8221;</p>
<p>Cheers&#8230;Dan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matty</title>
		<link>http://matty.co.za/2009/11/custom-url-rewrites-in-wordpress/comment-page-1/#comment-3432</link>
		<dc:creator>Matty</dc:creator>
		<pubDate>Sat, 19 Dec 2009 06:54:57 +0000</pubDate>
		<guid isPermaLink="false">http://matty.co.za/?p=701#comment-3432</guid>
		<description>Hi Brad,
Thanks for your comment.

I&#039;ll look into the call to flush_rewrite_rules.

I&#039;ll be writing a few more posts discussing custom rewrite rules in Wordpress, how to work with them and a few advanced uses. These may be followed up with a plugin. ;)

Cheers,
Matt.</description>
		<content:encoded><![CDATA[<p>Hi Brad,<br />
Thanks for your comment.</p>
<p>I&#8217;ll look into the call to flush_rewrite_rules.</p>
<p>I&#8217;ll be writing a few more posts discussing custom rewrite rules in WordPress, how to work with them and a few advanced uses. These may be followed up with a plugin. <img src='http://matty.co.za/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Cheers,<br />
Matt.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brad</title>
		<link>http://matty.co.za/2009/11/custom-url-rewrites-in-wordpress/comment-page-1/#comment-3431</link>
		<dc:creator>Brad</dc:creator>
		<pubDate>Wed, 16 Dec 2009 00:25:22 +0000</pubDate>
		<guid isPermaLink="false">http://matty.co.za/?p=701#comment-3431</guid>
		<description>It would be nice if you followed this up with a real plugin example, and I &quot;think&quot; the add_action( &#039;init&#039;, &#039;flush_rewrite_rules&#039; ); needs to be add_action( &#039;admin-init&#039;, &#039;flush_rewrite_rules&#039; );  BUT I am not 100% certain on that.  

Thanks

-Brad</description>
		<content:encoded><![CDATA[<p>It would be nice if you followed this up with a real plugin example, and I &#8220;think&#8221; the add_action( &#8216;init&#8217;, &#8216;flush_rewrite_rules&#8217; ); needs to be add_action( &#8216;admin-init&#8217;, &#8216;flush_rewrite_rules&#8217; );  BUT I am not 100% certain on that.  </p>
<p>Thanks</p>
<p>-Brad</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Object Caching 368/392 objects using disk: basic

Served from: matty.co.za @ 2012-05-10 12:27:37 -->
