user3700900
user3700900

Reputation: 1

Wordpress plugin with multiple pages

I'm creating a plugin and I'm a little confused by something. Basically, I have a menu on the Wordpress admin sidebar.

When you click on the menu, it takes you to the main page 'includes/main.php'. This works fine.

However, I have another page in the plugin folder 'includes/product.php'. When I click a button on the main page, I'd like to be able to send data to 'includes/product.php' and open that page as an admin page just like the main page, but I need to send data over when I click the button too.

I'm just not sure how to call the products.php page and have it as a Wordpress page that's part of the plugin, just like the main page. Anyone else experience this?

Upvotes: 0

Views: 1983

Answers (1)

paolo
paolo

Reputation: 2538

To use the wordpress framework in product.php, you have to include this page from your main.php. You could include it on the top of main.php and have an if statement that checks if there is post data, like this:

main.php

if(!empty($_POST)){
    include 'product.php';
    // you can let product.php do the rest of the rendering
}
else{
    // render your page
}

EDIT:

Another option is creating a submenu. http://codex.wordpress.org/Function_Reference/add_submenu_page

Upvotes: 1

Related Questions