Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Leave your permalink structure as it was and check out <a href="https://stackoverflow.com/questions/3154340">my answer on custom rewrite rules</a>.</p> <p>You could adapt the code like so;</p> <pre><code>function my_rewrite_rules($rules) { global $wp_rewrite; // the key is a regular expression // the value maps matches into a query string $my_rule = array( '(.+)/(.+)/?$' =&gt; 'index.php?pagename=matches[2]&amp;my_action=$matches[1]' ); return array_merge($my_rule, $rules); } add_filter('page_rewrite_rules', 'my_rewrite_rules'); function my_query_vars($vars) { // this value should match the rewrite rule query paramter above // I recommend using something more unique than 'action', as you // could collide with other plugins or WordPress core $my_vars = array('my_action'); return array_merge($my_vars, $vars); } add_filter('query_vars', 'my_query_vars'); </code></pre> <p>Now the page <code>my_page</code> should be available at <code>http://example.com/whatever/my_page</code> and <code>http://example.com/my_page</code>.</p> <p>You can get the value of <code>whatever</code> using <code>get_query_var('my_action')</code>.</p> <h2>Disclaimer</h2> <p>This may have undesired effects when viewing <em>children</em> pages or page attachments. You could get around this by passing an identifier in your rewrite, something to the effect of;</p> <pre><code>http://example.com/my_identifier/whatever/page </code></pre> <p>Note: You will need to edit the rewrite rule if you wish to do this. Every time you make changes to the code you will need to re-save your permalink structure to 'flush' the rules.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload