Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First off, giving the path that way is a bad idea, because if for any reason any of that changes, your plugin/theme breaks.<br> Ozh makes a great suggestion under the section <a href="http://planetozh.com/blog/2009/09/top-10-most-common-coding-mistakes-in-wordpress-plugins/" rel="nofollow">Hardcoded Paths</a> as far as those go...</p> <p>Secondly, you're most likely going to be better off using *query_vars*. Have a look at <a href="http://www.rlmseo.com/blog/passing-get-query-string-parameters-in-wordpress-url/" rel="nofollow">http://www.rlmseo.com/blog/passing-get-query-string-parameters-in-wordpress-url/</a> and possibly even <a href="http://planetozh.com/blog/2011/01/pretty-login-url-a-simple-rewrite-api-plugin-example/" rel="nofollow">http://planetozh.com/blog/2011/01/pretty-login-url-a-simple-rewrite-api-plugin-example/</a> for examples of how to do this.</p> <p>Also checkout the <a href="http://codex.wordpress.org/Class_Reference/WP_Rewrite" rel="nofollow">WP_Rewrite Class</a> as it has the best information on handling URL rewriting in WordPress.</p> <p>Thirdly, you need to hook your <code>setRewriteRules()</code> function to the <strong>init</strong> hook, because the first time the rules are flushed, your rules will be removed.</p> <p>So your code would look something like this (without any other corrections):</p> <pre><code>register_activation_hook(__FILE__,'activate'); register_deactivation_hook(__FILE__,'deactivate'); add_action('init', 'setRewriteRules'); function setRewriteRules() { add_rewrite_rule( 'plugin-url/$', '/wp-content/plugins/my-plugin/page.php', 'top' ); } function activate() { setRewriteRules(); global $wp_rewrite; $wp_rewrite-&gt;flush_rules(true); } function deactivate() { global $wp_rewrite; $wp_rewrite-&gt;flush_rules(true); } </code></pre> <p><br> <br></p> <h3>Rewrite Rule Flushing</h3> <p>Here's some tips on flushing your rewrite rules...</p> <ul> <li>Rewrite Rules are flushed automatically anytime you visit <strong>Settings > Permalink</strong> or anytime you make and save changes them in the Admin area.</li> <li>Adding <code>add_action('admin_init', 'deactivate');</code> might also be helpful so they are flushed anytime an Admin page is loaded.</li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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