I'm creating a plugin that is using the add_menu_page function to create a page for my plugin options. This means that the url for my plugins main options page is like this


Now, in my plugin options page there is a standard form with a drop down menu that lets people choose what data they want to display.

  <select name="data-to-get">
   <option value="1">Foo</option>
   <option value="2">Bar</option>
  <input type="submit" value="get-data">

Currently, when you select an option and click the button you are taken to this url:


This ends up loading a new page which is just blank. What I want to happen is this:


I know that WordPress has a built in function add_query_arg so I need to do something like this:

add_query_arg( 'data-to-get', '1', 'http://localhost:8888/LFB/wp-admin/admin.php?page=lfb-player-stats' );

However, where I'm stuck is that I don't know how to hook this in. It needs to be inserted after the select value has been chosen and when the get request from the form is sent.

1 Answer 1


Add a hidden input field to your form with name page and value my-wordpress-plugin, When the form is submitted it will be passed along with your other form data.

<input type="hidden" name="page" value="my-wordpress-plugin">

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.