PHP $_SERVER['PHP_SELF'] in Wordpress redirecting to the index page
action, forms, php, wordpress
Solution
The reason for this is that Wordpress runs (almost) everything through the index.php page and then handles which page to display via it's routing logic. You might try doing `var_dump($_SERVER);` to see which value you want but it's probably `$_SERVER['REQUEST_URI']`.
Problem
I have a wordpress website. There is a category page with a form on it to sort / filter the posts. I have tried using $_SERVER['PHP_SELF'] as the form action as i need to get the contents of the form to display the posts but when I do it redirects to the index page. Is there a reason for this? Or a better way to submit a form within wordpress. Thanks