<?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: How to Flush Permalink Rules with flush_rules()	</title>
	<atom:link href="https://www.shibashake.com/wp/how-to-flush-permalink-rules-with-flush_rules/feed" rel="self" type="application/rss+xml" />
	<link>https://shibashake.com/wp/how-to-flush-permalink-rules-with-flush_rules</link>
	<description>Adventures in WordPress</description>
	<lastBuildDate>Fri, 14 Nov 2014 22:30:22 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.9</generator>
	<item>
		<title>
		By: ShibaShake		</title>
		<link>https://shibashake.com/wp/how-to-flush-permalink-rules-with-flush_rules/comment-page-1#comment-469157</link>

		<dc:creator><![CDATA[ShibaShake]]></dc:creator>
		<pubDate>Fri, 14 Nov 2014 22:30:22 +0000</pubDate>
		<guid isPermaLink="false">http://shibashake.com/wordpress-theme/?p=8580#comment-469157</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://shibashake.com/wp/how-to-flush-permalink-rules-with-flush_rules/comment-page-1#comment-468847&quot;&gt;Ian Dunn&lt;/a&gt;.

Thanks! Will have to try it out.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://shibashake.com/wp/how-to-flush-permalink-rules-with-flush_rules/comment-page-1#comment-468847">Ian Dunn</a>.</p>
<p>Thanks! Will have to try it out.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Ian Dunn		</title>
		<link>https://shibashake.com/wp/how-to-flush-permalink-rules-with-flush_rules/comment-page-1#comment-468847</link>

		<dc:creator><![CDATA[Ian Dunn]]></dc:creator>
		<pubDate>Fri, 14 Nov 2014 20:14:02 +0000</pubDate>
		<guid isPermaLink="false">http://shibashake.com/wordpress-theme/?p=8580#comment-468847</guid>

					<description><![CDATA[A simpler solution for Multisite is to re-initialize the rewrite rules before flushing them:

https://gist.github.com/iandunn/c5a983d1a9d4b09d6d20]]></description>
			<content:encoded><![CDATA[<p>A simpler solution for Multisite is to re-initialize the rewrite rules before flushing them:</p>
<p><a href="https://gist.github.com/iandunn/c5a983d1a9d4b09d6d20" rel="nofollow ugc">https://gist.github.com/iandunn/c5a983d1a9d4b09d6d20</a></p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: snowboard mommy		</title>
		<link>https://shibashake.com/wp/how-to-flush-permalink-rules-with-flush_rules/comment-page-1#comment-75285</link>

		<dc:creator><![CDATA[snowboard mommy]]></dc:creator>
		<pubDate>Fri, 14 Jun 2013 01:04:16 +0000</pubDate>
		<guid isPermaLink="false">http://shibashake.com/wordpress-theme/?p=8580#comment-75285</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://shibashake.com/wp/how-to-flush-permalink-rules-with-flush_rules/comment-page-1#comment-75280&quot;&gt;snowboard mommy&lt;/a&gt;.

I&#039;m back ... I was having trouble with WordPress adding yet another &quot;/blog/&quot; before my custom post type slug.  I had to set the &quot;with_front&quot; property of the custom post type rewrite setting to &quot;False&quot; (and not put it in quotes!!! yeah, that was kinda stupid).  Anyway, I just though I&#039;d mention it in case anyone else crazy enough to use both Multisite and Custom Post Types comes along.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://shibashake.com/wp/how-to-flush-permalink-rules-with-flush_rules/comment-page-1#comment-75280">snowboard mommy</a>.</p>
<p>I&#8217;m back &#8230; I was having trouble with WordPress adding yet another &#8220;/blog/&#8221; before my custom post type slug.  I had to set the &#8220;with_front&#8221; property of the custom post type rewrite setting to &#8220;False&#8221; (and not put it in quotes!!! yeah, that was kinda stupid).  Anyway, I just though I&#8217;d mention it in case anyone else crazy enough to use both Multisite and Custom Post Types comes along.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: snowboard mommy		</title>
		<link>https://shibashake.com/wp/how-to-flush-permalink-rules-with-flush_rules/comment-page-1#comment-75280</link>

		<dc:creator><![CDATA[snowboard mommy]]></dc:creator>
		<pubDate>Thu, 13 Jun 2013 23:03:41 +0000</pubDate>
		<guid isPermaLink="false">http://shibashake.com/wordpress-theme/?p=8580#comment-75280</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://shibashake.com/wp/how-to-flush-permalink-rules-with-flush_rules/comment-page-1#comment-75274&quot;&gt;ShibaShake&lt;/a&gt;.

Great! That makes sense.  Thank you for the speedy reply. You are pretty, awesome, you know, right? : )]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://shibashake.com/wp/how-to-flush-permalink-rules-with-flush_rules/comment-page-1#comment-75274">ShibaShake</a>.</p>
<p>Great! That makes sense.  Thank you for the speedy reply. You are pretty, awesome, you know, right? : )</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: ShibaShake		</title>
		<link>https://shibashake.com/wp/how-to-flush-permalink-rules-with-flush_rules/comment-page-1#comment-75274</link>

		<dc:creator><![CDATA[ShibaShake]]></dc:creator>
		<pubDate>Thu, 13 Jun 2013 18:43:56 +0000</pubDate>
		<guid isPermaLink="false">http://shibashake.com/wordpress-theme/?p=8580#comment-75274</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://shibashake.com/wp/how-to-flush-permalink-rules-with-flush_rules/comment-page-1#comment-75272&quot;&gt;snowboard mommy&lt;/a&gt;.

I pass in the permastruct variable myself. It is simply the permalink structure I want to set my object to, for example-
&quot;/gallery/%monthnum%/%category%/%gallery%&quot;

I call the flush functions during activation and deactivation.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://shibashake.com/wp/how-to-flush-permalink-rules-with-flush_rules/comment-page-1#comment-75272">snowboard mommy</a>.</p>
<p>I pass in the permastruct variable myself. It is simply the permalink structure I want to set my object to, for example-<br />
&#8220;/gallery/%monthnum%/%category%/%gallery%&#8221;</p>
<p>I call the flush functions during activation and deactivation.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: snowboard mommy		</title>
		<link>https://shibashake.com/wp/how-to-flush-permalink-rules-with-flush_rules/comment-page-1#comment-75273</link>

		<dc:creator><![CDATA[snowboard mommy]]></dc:creator>
		<pubDate>Thu, 13 Jun 2013 15:39:34 +0000</pubDate>
		<guid isPermaLink="false">http://shibashake.com/wordpress-theme/?p=8580#comment-75273</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://shibashake.com/wp/how-to-flush-permalink-rules-with-flush_rules/comment-page-1#comment-75272&quot;&gt;snowboard mommy&lt;/a&gt;.

(actually it&#039;s the $permastruct var that&#039;s being passed, sorry about that)]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://shibashake.com/wp/how-to-flush-permalink-rules-with-flush_rules/comment-page-1#comment-75272">snowboard mommy</a>.</p>
<p>(actually it&#8217;s the $permastruct var that&#8217;s being passed, sorry about that)</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: snowboard mommy		</title>
		<link>https://shibashake.com/wp/how-to-flush-permalink-rules-with-flush_rules/comment-page-1#comment-75272</link>

		<dc:creator><![CDATA[snowboard mommy]]></dc:creator>
		<pubDate>Thu, 13 Jun 2013 15:38:36 +0000</pubDate>
		<guid isPermaLink="false">http://shibashake.com/wordpress-theme/?p=8580#comment-75272</guid>

					<description><![CDATA[Hi Shiba,

Thanks for this information. How/where do we call the rewrite functions for multisite?  Is it part of the activation routine, and where is the $permalink variable is being passed from?  

Thanks!]]></description>
			<content:encoded><![CDATA[<p>Hi Shiba,</p>
<p>Thanks for this information. How/where do we call the rewrite functions for multisite?  Is it part of the activation routine, and where is the $permalink variable is being passed from?  </p>
<p>Thanks!</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Thomas		</title>
		<link>https://shibashake.com/wp/how-to-flush-permalink-rules-with-flush_rules/comment-page-1#comment-30224</link>

		<dc:creator><![CDATA[Thomas]]></dc:creator>
		<pubDate>Mon, 22 Oct 2012 01:07:37 +0000</pubDate>
		<guid isPermaLink="false">http://shibashake.com/wordpress-theme/?p=8580#comment-30224</guid>

					<description><![CDATA[You can also add rewrite rules within the rewrite_rules_array filter directly. I wrote up this gem earlier today with the purpose of manually creating callback linked action pages. The usage would be something like:

new action_page(&#039;cart&#039;, array(&#039;items&#039;));
add_action(&#039;admin_post_nopriv_cart&#039;, array($this, &#039;display_cart&#039;));
add_action(&#039;admin_post_cart&#039;, array($this, &#039;display_cart&#039;));

[code]
&#060;?php
action_page::init();
class action_page {

	protected $action;
	protected $vars;
		
	public static function init() {
		add_action(&#039;template_redirect&#039;, array(__CLASS__, &#039;action_redirect&#039;));	
	}
	
	public function __construct( $action, $vars = array()) {
	
		$this-&#062;action = $action;
		$this-&#062;vars = $vars;
				
		add_filter(&#039;query_vars&#039;, array($this, &#039;add_query_vars&#039;));
		add_filter(&#039;rewrite_rules_array&#039;, array($this, &#039;add_rewrite_rules&#039;));
		add_filter(&#034;{$action}_query_vars&#034;, array($this, &#039;import_vars&#039;));
	}
	
	public function add_query_vars( $vars ) {
		$vars[] = &#039;action&#039;;
		return array_merge($vars, $this-&#062;vars);
	}
	
	public function add_rewrite_rules( $rules ) {
		$regex = implode(&#034;/&#034;, $this-&#062;regex());
		$regex = !empty($regex) ? &#034;{$regex}/?$&#034; : &#034;?$&#034;;
		$rules = array(&#034;{$this-&#062;action}/{$regex}&#034; =&#062; $this-&#062;match()) + $rules;
		return $rules;
	}
	
	protected function regex() {
		$m = array_fill_keys($this-&#062;vars, &#034;([^/]+)&#034;);
		return apply_filters(&#034;{$this-&#062;action}_regex&#034;, $m);
	}
	
	protected function match() {
		$size = sizeof($this-&#062;vars);
		$match = &#034;/index.php?action={$this-&#062;action}&#034;;
		for($i = 0; $i &#060; $size; $i++) { 
			$m = $i + 1;
			$match .= &#034;&#038;{$this-&#062;vars[$i]}=\$matches[{$m}]&#034;; 
		}
		return apply_filters(&#034;{$this-&#062;action}_match&#034;, $match);
	}
	
	public function import_vars( $vars = array() ) {
		global $wp_query;
		$vars += array_intersect_key($wp_query-&#062;query_vars, array_flip($this-&#062;vars));
		return $vars;
	}
	
	
	public static function action_redirect() {
		if($action = get_query_var(&#039;action&#039;)) {
			$vars = apply_filters(&#034;{$action}_query_vars&#034;, array());
			$action = wp_validate_auth_cookie() ? &#034;admin_post_{$action}&#034; : &#034;admin_post_nopriv_{$action}&#034;;
			do_action($action, $vars);
		}
	}
}
[/code]]]></description>
			<content:encoded><![CDATA[<p>You can also add rewrite rules within the rewrite_rules_array filter directly. I wrote up this gem earlier today with the purpose of manually creating callback linked action pages. The usage would be something like:</p>
<p>new action_page(&#8216;cart&#8217;, array(&#8216;items&#8217;));<br />
add_action(&#8216;admin_post_nopriv_cart&#8217;, array($this, &#8216;display_cart&#8217;));<br />
add_action(&#8216;admin_post_cart&#8217;, array($this, &#8216;display_cart&#8217;));</p>
<pre class="brush: plain; title: ; notranslate">
&lt;?php
action_page::init();
class action_page {

	protected $action;
	protected $vars;
		
	public static function init() {
		add_action(&#039;template_redirect&#039;, array(__CLASS__, &#039;action_redirect&#039;));	
	}
	
	public function __construct( $action, $vars = array()) {
	
		$this-&gt;action = $action;
		$this-&gt;vars = $vars;
				
		add_filter(&#039;query_vars&#039;, array($this, &#039;add_query_vars&#039;));
		add_filter(&#039;rewrite_rules_array&#039;, array($this, &#039;add_rewrite_rules&#039;));
		add_filter(&quot;{$action}_query_vars&quot;, array($this, &#039;import_vars&#039;));
	}
	
	public function add_query_vars( $vars ) {
		$vars[] = &#039;action&#039;;
		return array_merge($vars, $this-&gt;vars);
	}
	
	public function add_rewrite_rules( $rules ) {
		$regex = implode(&quot;/&quot;, $this-&gt;regex());
		$regex = !empty($regex) ? &quot;{$regex}/?$&quot; : &quot;?$&quot;;
		$rules = array(&quot;{$this-&gt;action}/{$regex}&quot; =&gt; $this-&gt;match()) + $rules;
		return $rules;
	}
	
	protected function regex() {
		$m = array_fill_keys($this-&gt;vars, &quot;([^/]+)&quot;);
		return apply_filters(&quot;{$this-&gt;action}_regex&quot;, $m);
	}
	
	protected function match() {
		$size = sizeof($this-&gt;vars);
		$match = &quot;/index.php?action={$this-&gt;action}&quot;;
		for($i = 0; $i &lt; $size; $i++) { 
			$m = $i + 1;
			$match .= &quot;&amp;{$this-&gt;vars[$i]}=\$matches[{$m}]&quot;; 
		}
		return apply_filters(&quot;{$this-&gt;action}_match&quot;, $match);
	}
	
	public function import_vars( $vars = array() ) {
		global $wp_query;
		$vars += array_intersect_key($wp_query-&gt;query_vars, array_flip($this-&gt;vars));
		return $vars;
	}
	
	
	public static function action_redirect() {
		if($action = get_query_var(&#039;action&#039;)) {
			$vars = apply_filters(&quot;{$action}_query_vars&quot;, array());
			$action = wp_validate_auth_cookie() ? &quot;admin_post_{$action}&quot; : &quot;admin_post_nopriv_{$action}&quot;;
			do_action($action, $vars);
		}
	}
}
</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: staff		</title>
		<link>https://shibashake.com/wp/how-to-flush-permalink-rules-with-flush_rules/comment-page-1#comment-8977</link>

		<dc:creator><![CDATA[staff]]></dc:creator>
		<pubDate>Tue, 06 Dec 2011 15:30:42 +0000</pubDate>
		<guid isPermaLink="false">http://shibashake.com/wordpress-theme/?p=8580#comment-8977</guid>

					<description><![CDATA[Still a bit confuse here.. I am trying to add a new category using the WP API (multiple sites), the permalinks are not refreshing. 
So when a visitor goes to the page on the site it throws a 404 error. I have to manually go to to wp-admin -&#062; settings -&#062; permalinks and save to solve the problem.

Here is what I am doing that is not working:

add_action(&#039;init&#039;, &#039;flush_permalinks&#039;);

function flush_permalinks(){
  global $wp_rewrite;
  $wp_rewrite-&#062;set_permalink_structure(&#039;/%postname%/&#039;);
  //$wp_rewrite-&#062;flush_rules();
 // flush_rewrite_rules();
}

Could you find my error? Thanks.]]></description>
			<content:encoded><![CDATA[<p>Still a bit confuse here.. I am trying to add a new category using the WP API (multiple sites), the permalinks are not refreshing.<br />
So when a visitor goes to the page on the site it throws a 404 error. I have to manually go to to wp-admin -&gt; settings -&gt; permalinks and save to solve the problem.</p>
<p>Here is what I am doing that is not working:</p>
<p>add_action(&#8216;init&#8217;, &#8216;flush_permalinks&#8217;);</p>
<p>function flush_permalinks(){<br />
  global $wp_rewrite;<br />
  $wp_rewrite-&gt;set_permalink_structure(&#8216;/%postname%/&#8217;);<br />
  //$wp_rewrite-&gt;flush_rules();<br />
 // flush_rewrite_rules();<br />
}</p>
<p>Could you find my error? Thanks.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: ShibaShake		</title>
		<link>https://shibashake.com/wp/how-to-flush-permalink-rules-with-flush_rules/comment-page-1#comment-5907</link>

		<dc:creator><![CDATA[ShibaShake]]></dc:creator>
		<pubDate>Mon, 18 Jul 2011 19:48:26 +0000</pubDate>
		<guid isPermaLink="false">http://shibashake.com/wordpress-theme/?p=8580#comment-5907</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://shibashake.com/wp/how-to-flush-permalink-rules-with-flush_rules/comment-page-1#comment-5859&quot;&gt;rashid&lt;/a&gt;.

$gallery_structure contains a regular WP permalink structure, e.g. /galleries/%year%/%monthnum%/%gallery%. 
http://shibashake.com/wordpress-theme/custom-post-type-permalinks-part-2]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://shibashake.com/wp/how-to-flush-permalink-rules-with-flush_rules/comment-page-1#comment-5859">rashid</a>.</p>
<p>$gallery_structure contains a regular WP permalink structure, e.g. /galleries/%year%/%monthnum%/%gallery%.<br />
<a href="http://shibashake.com/wordpress-theme/custom-post-type-permalinks-part-2" rel="nofollow ugc">http://shibashake.com/wordpress-theme/custom-post-type-permalinks-part-2</a></p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/

Object Caching 11/23 objects using disk
Page Caching using disk: enhanced 
Content Delivery Network via Amazon Web Services: CloudFront: cdn.shibashake.com
Lazy Loading (feed)
Minified using disk
Database Caching 2/26 queries in 0.011 seconds using disk (Request-wide modification query)

Served from: www.shibashake.com @ 2024-12-16 21:21:11 by W3 Total Cache
-->