Posted By

thommeredith on 08/29/11


Tagged

wordpress


Versions (?)

Getting/Setting Variables Rewrite URL Wordpress


 / Published in: PHP
 

  1. function add_my_var($public_query_vars) {
  2. $public_query_vars[] = 'myvar';
  3. return $public_query_vars;
  4. }
  5.  
  6. add_filter('query_vars', 'add_my_var');
  7.  
  8. function do_rewrite() {
  9. add_rewrite_rule('artists/(.+?)/(.+?)?$', 'index.php?pagename=artists/$matches[1]&myvar=$matches[2]','top');
  10. }
  11.  
  12. add_action('init', 'do_rewrite');

Report this snippet  

You need to login to post a comment.