<?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 Post Type and Permalink</title>
	<atom:link href="http://wpengineer.com/2044/custom-post-type-and-permalink/feed/" rel="self" type="application/rss+xml" />
	<link>http://wpengineer.com/2044/custom-post-type-and-permalink/</link>
	<description>WordPress News, Hacks, Tips, Tutorials, Plugins and Themes</description>
	<lastBuildDate>Wed, 08 Feb 2012 19:48:58 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Ken</title>
		<link>http://wpengineer.com/2044/custom-post-type-and-permalink/#comment-8390</link>
		<dc:creator>Ken</dc:creator>
		<pubDate>Wed, 04 May 2011 15:22:18 +0000</pubDate>
		<guid isPermaLink="false">http://wpengineer.com/?p=2044#comment-8390</guid>
		<description>Don&#039;t call flush after the register function. (Many examples above do this.)

Instead, add two functions, one attached to the &quot;register_activation_hook( __FILE__, &#039;activate_cb&#039; );&quot; which in turn adds an action to &#039;init&#039; (priority 11 just to be sure) and that function in turn flushes the rewrite. Otherwise, you are flushing on every single page load (not good).</description>
		<content:encoded><![CDATA[<p>Don't call flush after the register function. (Many examples above do this.)</p>
<p>Instead, add two functions, one attached to the "register_activation_hook( __FILE__, 'activate_cb' );" which in turn adds an action to 'init' (priority 11 just to be sure) and that function in turn flushes the rewrite. Otherwise, you are flushing on every single page load (not good).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pippin</title>
		<link>http://wpengineer.com/2044/custom-post-type-and-permalink/#comment-8225</link>
		<dc:creator>Pippin</dc:creator>
		<pubDate>Sun, 17 Apr 2011 02:38:35 +0000</pubDate>
		<guid isPermaLink="false">http://wpengineer.com/?p=2044#comment-8225</guid>
		<description>Do you know why you shouldn&#039;t put it in, say, a function called by an init hook? I&#039;ve been testing it and it seems to work fine . . .</description>
		<content:encoded><![CDATA[<p>Do you know why you shouldn't put it in, say, a function called by an init hook? I've been testing it and it seems to work fine . . .</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: WordPress Custom Post Types (Teil2): Selbst individuelle Inhaltstypen und Taxonomies anlegen &#124; Elmastudio</title>
		<link>http://wpengineer.com/2044/custom-post-type-and-permalink/#comment-6450</link>
		<dc:creator>WordPress Custom Post Types (Teil2): Selbst individuelle Inhaltstypen und Taxonomies anlegen &#124; Elmastudio</dc:creator>
		<pubDate>Tue, 01 Feb 2011 20:43:06 +0000</pubDate>
		<guid isPermaLink="false">http://wpengineer.com/?p=2044#comment-6450</guid>
		<description>[...] Deaktivierung tun. Mehr Infos zu Custom Posts Types und Permalinks fin­dest du auch im Artikel »Custom Post Types and Permalinks« auf [...]</description>
		<content:encoded><![CDATA[<p>[...] Deaktivierung tun. Mehr Infos zu Custom Posts Types und Permalinks fin­dest du auch im Artikel »Custom Post Types and Permalinks« auf [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David F. Carr</title>
		<link>http://wpengineer.com/2044/custom-post-type-and-permalink/#comment-5511</link>
		<dc:creator>David F. Carr</dc:creator>
		<pubDate>Fri, 10 Dec 2010 13:52:33 +0000</pubDate>
		<guid isPermaLink="false">http://wpengineer.com/?p=2044#comment-5511</guid>
		<description>I&#039;m looking for help with a similar problem here:

http://wordpress.org/support/topic/need-help-diagnosing-permalink-problem-reports?replies=1

My plugin code works fine on my site and those of some other users who are happy with it, but I&#039;m also getting isolated reports of 404 errors when people try to use the permalinks.</description>
		<content:encoded><![CDATA[<p>I'm looking for help with a similar problem here:</p>
<p><a href="http://wordpress.org/support/topic/need-help-diagnosing-permalink-problem-reports?replies=1" rel="nofollow">http://wordpress.org/support/topic/need-help-diagnosing-permalink-problem-reports?replies=1</a></p>
<p>My plugin code works fine on my site and those of some other users who are happy with it, but I'm also getting isolated reports of 404 errors when people try to use the permalinks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe</title>
		<link>http://wpengineer.com/2044/custom-post-type-and-permalink/#comment-5213</link>
		<dc:creator>Joe</dc:creator>
		<pubDate>Mon, 22 Nov 2010 19:54:15 +0000</pubDate>
		<guid isPermaLink="false">http://wpengineer.com/?p=2044#comment-5213</guid>
		<description>Hi there,

I&#039;m trying to use this method with custom date meta for my permalink rewrite.  I can&#039;t figure out for the life of me why I can&#039;t get around the 404 issue.  Ive even added in your flush_rewrite_rules into my code and nothing.  

Settings &gt; Permalink Structure:  /%category%/%postname%/

Here is my function below- it&#039;s working fine for creating the actual permalink but i cannot access the post without getting the 404.

&lt;code&gt;add_filter(&#039;post_type_link&#039;,&#039;calendar_link_filter&#039;,1,3);

function calendar_link_filter( $post_link, $id = 0, $leavename = FALSE ) {
        $post = get_post($id);
        if($post-&gt;post_type != &#039;super_duper&#039;) {
                return $post_link;
        }
        $date = get_post_meta($post-&gt;ID,&#039;event_start_date&#039;,true);
        $date = strtotime($date);
        $str = $post_link;
        $str = str_replace(&#039;%cal_year%&#039;,date(&quot;Y&quot;,$date),$str);
        $str = str_replace(&#039;%cal_month%&#039;,date(&quot;m&quot;,$date),$str);
        $str = str_replace(&#039;%cal_day%&#039;,date(&quot;d&quot;,$date),$str);
        return $str;
		
}


add_action( &#039;init&#039;, &#039;create_my_post_types&#039; );

function create_my_post_types() {
	register_post_type( &#039;super_duper&#039;,
		array(
			&#039;labels&#039; =&gt; array(
				&#039;name&#039; =&gt; __( &#039;Super Dupers&#039; ),
				&#039;singular_name&#039; =&gt; __( &#039;Super Duper&#039; )
			),
			&#039;hierarchical&#039; =&gt; false,
			&#039;show_ui&#039; =&gt; true, // UI in admin panel
            &#039;publicly_queryable&#039; =&gt; true,
            &#039;rewrite&#039; =&gt; true,
			&#039;public&#039; =&gt; true,
			&#039;rewrite&#039; =&gt; array(&#039;slug&#039; =&gt; &#039;events8/%cal_year%/%cal_month%/%cal_day%&#039;),
			
			
		)
	);
	flush_rewrite_rules();
}&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Hi there,</p>
<p>I'm trying to use this method with custom date meta for my permalink rewrite.  I can't figure out for the life of me why I can't get around the 404 issue.  Ive even added in your flush_rewrite_rules into my code and nothing.  </p>
<p>Settings &gt; Permalink Structure:  /%category%/%postname%/</p>
<p>Here is my function below- it's working fine for creating the actual permalink but i cannot access the post without getting the 404.</p>
<p><code>add_filter('post_type_link','calendar_link_filter',1,3);</code></p>
<p>function calendar_link_filter( $post_link, $id = 0, $leavename = FALSE ) {<br />
        $post = get_post($id);<br />
        if($post-&gt;post_type != 'super_duper') {<br />
                return $post_link;<br />
        }<br />
        $date = get_post_meta($post-&gt;ID,'event_start_date',true);<br />
        $date = strtotime($date);<br />
        $str = $post_link;<br />
        $str = str_replace('%cal_year%',date("Y",$date),$str);<br />
        $str = str_replace('%cal_month%',date("m",$date),$str);<br />
        $str = str_replace('%cal_day%',date("d",$date),$str);<br />
        return $str;</p>
<p>}</p>
<p>add_action( 'init', 'create_my_post_types' );</p>
<p>function create_my_post_types() {<br />
	register_post_type( 'super_duper',<br />
		array(<br />
			'labels' =&gt; array(<br />
				'name' =&gt; __( 'Super Dupers' ),<br />
				'singular_name' =&gt; __( 'Super Duper' )<br />
			),<br />
			'hierarchical' =&gt; false,<br />
			'show_ui' =&gt; true, // UI in admin panel<br />
            'publicly_queryable' =&gt; true,<br />
            'rewrite' =&gt; true,<br />
			'public' =&gt; true,<br />
			'rewrite' =&gt; array('slug' =&gt; 'events8/%cal_year%/%cal_month%/%cal_day%'),</p>
<p>		)<br />
	);<br />
	flush_rewrite_rules();<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jared</title>
		<link>http://wpengineer.com/2044/custom-post-type-and-permalink/#comment-5207</link>
		<dc:creator>Jared</dc:creator>
		<pubDate>Sun, 21 Nov 2010 20:42:37 +0000</pubDate>
		<guid isPermaLink="false">http://wpengineer.com/?p=2044#comment-5207</guid>
		<description>holy crap....i&#039;ve been looking for a solution to this for almost 2 hours and all i had to do was resave my permalink structure....lame-0 but at least I got it fixed! Thanks!</description>
		<content:encoded><![CDATA[<p>holy crap....i've been looking for a solution to this for almost 2 hours and all i had to do was resave my permalink structure....lame-0 but at least I got it fixed! Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vered</title>
		<link>http://wpengineer.com/2044/custom-post-type-and-permalink/#comment-5101</link>
		<dc:creator>Vered</dc:creator>
		<pubDate>Mon, 01 Nov 2010 11:05:46 +0000</pubDate>
		<guid isPermaLink="false">http://wpengineer.com/?p=2044#comment-5101</guid>
		<description>Thanx for the post.
And special thanx to Karl for the example - that&#039;s exactly what I was looking for!</description>
		<content:encoded><![CDATA[<p>Thanx for the post.<br />
And special thanx to Karl for the example - that's exactly what I was looking for!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Amr events version 1.0 available &#124; amr ical events</title>
		<link>http://wpengineer.com/2044/custom-post-type-and-permalink/#comment-5095</link>
		<dc:creator>Amr events version 1.0 available &#124; amr ical events</dc:creator>
		<pubDate>Sat, 30 Oct 2010 10:56:11 +0000</pubDate>
		<guid isPermaLink="false">http://wpengineer.com/?p=2044#comment-5095</guid>
		<description>[...] you may need to &#8220;flush&#8221; them). The plugin does flush the rewrite rules on activation as recommended, however some websites seem to require a manual flush.  To do so, go to your admin menu settings [...]</description>
		<content:encoded><![CDATA[<p>[...] you may need to &#8220;flush&#8221; them). The plugin does flush the rewrite rules on activation as recommended, however some websites seem to require a manual flush.  To do so, go to your admin menu settings [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Clarke</title>
		<link>http://wpengineer.com/2044/custom-post-type-and-permalink/#comment-5072</link>
		<dc:creator>Jonathan Clarke</dc:creator>
		<pubDate>Mon, 25 Oct 2010 13:57:07 +0000</pubDate>
		<guid isPermaLink="false">http://wpengineer.com/?p=2044#comment-5072</guid>
		<description>Ah, good idea to throw everything into init.</description>
		<content:encoded><![CDATA[<p>Ah, good idea to throw everything into init.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karl Haro von Mogel</title>
		<link>http://wpengineer.com/2044/custom-post-type-and-permalink/#comment-5066</link>
		<dc:creator>Karl Haro von Mogel</dc:creator>
		<pubDate>Sun, 24 Oct 2010 01:23:09 +0000</pubDate>
		<guid isPermaLink="false">http://wpengineer.com/?p=2044#comment-5066</guid>
		<description>I just tried this out, and it worked beautifully to fix my permalink issues. In my blog theme, I have the custom post type initialized in my functions.php file. I added the flush_rewrite_rules(); function to the file, within the create_my_post_types() function that initializes my custom post type (self-named, not a wordpress function) , but after the register_post_type() function that defines the parameters of the custom post type. confused? Well here&#039;s my code, hopefully this will display properly:
&lt;code&gt;
add_action( &#039;init&#039;, &#039;create_my_post_types&#039; );

function create_my_post_types() {
	register_post_type( &#039;genera&#039;,
		array(
			&#039;labels&#039; =&gt; array(
	            &#039;name&#039; =&gt; __( &#039;GENERA&#039; ),
	            &#039;singular_name&#039; =&gt; __( &#039;GENERA Entry&#039; ),
	            &#039;add_new&#039; =&gt; __( &#039;Add New&#039; ),
	            &#039;add_new_item&#039; =&gt; __( &#039;Add New GENERA Entry&#039; ),
            	&#039;edit&#039; =&gt; __( &#039;Edit&#039; ),
            	&#039;edit_item&#039; =&gt; __( &#039;Edit GENERA Entry&#039; ),
	            &#039;new_item&#039; =&gt; __( &#039;New GENERA Entry&#039; ),
	            &#039;view&#039; =&gt; __( &#039;View GENERA&#039; ),
	            &#039;view_item&#039; =&gt; __( &#039;View GENERA Entry&#039; ),
	            &#039;search_items&#039; =&gt; __( &#039;Search GENERA&#039; ),
	            &#039;not_found&#039; =&gt; __( &#039;No GENERA Entries found&#039; ),
	            &#039;not_found_in_trash&#039; =&gt; __( &#039;No GENERA Entries found in Trash&#039; ),
	            &#039;parent&#039; =&gt; __( &#039;Parent GENERA Entry&#039; ),
),
			&#039;public&#039; =&gt; true,
			&#039;show_ui&#039; =&gt; true,
            &#039;publicly_queryable&#039; =&gt; true,
			&#039;rewrite&#039; =&gt; true,
            &#039;exclude_from_search&#039; =&gt; false,
			&#039;menu_position&#039; =&gt; 20,
			/* Global control over capabilities. */
            &#039;capability_type&#039; =&gt; &#039;post&#039;,
            &#039;supports&#039; =&gt; array( &#039;title&#039;, &#039;editor&#039;, &#039;comments&#039;, &#039;trackbacks&#039;, &#039;revisions&#039;, &#039;author&#039;, &#039;excerpt&#039;, &#039;custom-fields&#039;, &#039;thumbnail&#039;, &#039;page-attributes&#039; ),
		)
	);
	flush_rewrite_rules();
}
&lt;/code&gt;
in order to see the new permalink structure, you will of course have to have &#039;rewrite&#039; set to =&gt; true</description>
		<content:encoded><![CDATA[<p>I just tried this out, and it worked beautifully to fix my permalink issues. In my blog theme, I have the custom post type initialized in my functions.php file. I added the flush_rewrite_rules(); function to the file, within the create_my_post_types() function that initializes my custom post type (self-named, not a wordpress function) , but after the register_post_type() function that defines the parameters of the custom post type. confused? Well here's my code, hopefully this will display properly:<br />
<code><br />
add_action( 'init', 'create_my_post_types' );</code></p>
<p>function create_my_post_types() {<br />
	register_post_type( 'genera',<br />
		array(<br />
			'labels' =&gt; array(<br />
	            'name' =&gt; __( 'GENERA' ),<br />
	            'singular_name' =&gt; __( 'GENERA Entry' ),<br />
	            'add_new' =&gt; __( 'Add New' ),<br />
	            'add_new_item' =&gt; __( 'Add New GENERA Entry' ),<br />
            	'edit' =&gt; __( 'Edit' ),<br />
            	'edit_item' =&gt; __( 'Edit GENERA Entry' ),<br />
	            'new_item' =&gt; __( 'New GENERA Entry' ),<br />
	            'view' =&gt; __( 'View GENERA' ),<br />
	            'view_item' =&gt; __( 'View GENERA Entry' ),<br />
	            'search_items' =&gt; __( 'Search GENERA' ),<br />
	            'not_found' =&gt; __( 'No GENERA Entries found' ),<br />
	            'not_found_in_trash' =&gt; __( 'No GENERA Entries found in Trash' ),<br />
	            'parent' =&gt; __( 'Parent GENERA Entry' ),<br />
),<br />
			'public' =&gt; true,<br />
			'show_ui' =&gt; true,<br />
            'publicly_queryable' =&gt; true,<br />
			'rewrite' =&gt; true,<br />
            'exclude_from_search' =&gt; false,<br />
			'menu_position' =&gt; 20,<br />
			/* Global control over capabilities. */<br />
            'capability_type' =&gt; 'post',<br />
            'supports' =&gt; array( 'title', 'editor', 'comments', 'trackbacks', 'revisions', 'author', 'excerpt', 'custom-fields', 'thumbnail', 'page-attributes' ),<br />
		)<br />
	);<br />
	flush_rewrite_rules();<br />
}<br />
<br />
in order to see the new permalink structure, you will of course have to have 'rewrite' set to =&gt; true</p>
]]></content:encoded>
	</item>
</channel>
</rss>

