SH10151
SH10151

Reputation: 974

How can I call another page or function in my custom Wordpress plugin?

I've created a custom Wordpress plugin. I set a menu item on the left side of the Admin panel which links to the main page for the plugin which I can access. Works fine.

I then put a link on that main plugin page in order to be able to click a link that runs a PHP script, but it returns a blank page. This URL syntax is confusing within the Admin section for Plugins. I just want to call my script!

I'm doing what is suggested here, but it just serves up a blank page: http://codex.wordpress.org/Plugin_API/Action_Reference/admin_post_%28action%29

Why is it so hard to just link to a page and call a function from a Plugin within the Admin section? I have Debug Mode enabled, too.

Thanks.

Upvotes: 1

Views: 2086

Answers (1)

SH10151
SH10151

Reputation: 974

Wow, this was confusing. With a little help from http://clivern.com/adding-menus-and-submenus-for-wordpress-plugins/ I now understand that you can't just link to your own plugin functions and pages in the Wordpress Admin section. You have to create menu items using add_menu_page() and add_submenu_page () that are then interpreted by Wordpress as blocks of code shown on a page...

Man this is frustrating and strange and it took HOURS just to figure this stupid little thing out. Really poorly documented. I found a few other things in the "Plugin Handbook" but nothing to do with this. They don't get into how to write a plugin that has admin-only functionality and being able to link to those functions and how the Admin URL syntax works.

Upvotes: 0

Related Questions