I am writing a very small wordpress plugin but I seem to be having issues on using it. The add_action(‘template_redirect’, ‘example_function’); works as it should be and the function is called correctly.
The line that is not working is: if(preg_match(‘#^/api/(.*)$#’, $_SERVER[‘REQUEST_URI’], $match)) { The /api/ part and the ^/ are wrong.
Can somebody help me fixing my line? Thank you.
try this:
(this will only work if the file runs from the top directory of your domain)
if your path is inside another dir (like: http://www.mydomain.com/dir/api/bla.php) remove the
^from the beginning of the pattern