Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Let's say I create a plugin with a menu page and three different submenu pages. How can I determine the URI for each one of them? For example, if I want to have a link on one of the pages to one of the other pages, how do I do that?

I had this problem before, too, when I created a form to gather some information. I ultimately solved it by having the page that defined the form handle it. Like this:

<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">

How would I let another page handle the form data, i.e. what would I put in the action parameter.

I noticed some people hardcode the URI one way or another, for example through

$_SERVER['PHP_SELF'].'?page=slug

But that won't work with all URL schemes.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

You can dynamically generate those URLs like this:

$url = add_query_arg( array(
    'page' => 'slug', // whatever the page slug should be, either for this page or the other pages
), admin_url( 'options-general.php' ) );
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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