Getting back a permalink from custom url

Question

okay i have made my own rewrite rule, with the add_rewrite_rule function in wordpress to get a custom url, for an plugin page.

add_action( 'init', function() {

  add_rewrite_rule( 'login/?$', 'index.php?function=login', 'top' );
  add_rewrite_rule( 'login/([a-zA-Z0-9]+)/?$', 'index.php?function=login&id=$matches[1]', 'top' );

});

add_filter( 'query_vars', function($query_vars) {

  $query_vars[] = 'function';
  $query_vars[] = 'id';
  return $query_vars;

});

This works great and i can visit the page [domainname.com]/login to visit the page. Now the problem how do i best get a propper permalink for this page, one that works both with rewrite rules turned on, and off.

I tried using the get_permalink() function, and that works with pages, post on other stuff, but is there a function working in similar fashion that can get custom url’s like this?

0
bymem 4 months 0 Answers 13 views 0

Leave an answer