WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Hay I am creating my first wordpress plugin. Everything is going well so far. I have been able to add a new navigation tab to the dashboard which links to a function which basicalliy uses 'include' to spit the content of a HTML page onto the wordpress admin area.

Heres my code

add_action('admin_menu', 'rooms_menu');

function rooms_menu() {
    add_menu_page('Rooms', 'Rooms', 'read', 'rooms-admin', 'show_hotel_dashboard', '' , 9);

function show_hotel_dashboard(){
    include 'dashboard.html';

pretty straight forward, the dashboard.html page is a very simple html page. Now, heres my issue, within this dasboard.html page, how do i link some links to functions?

Say i have a link which is

<a href='do_action.php'>Do action</a>

when i click that link it actually goes to do_action.php not the action within my plugin.

Any ideas?

share|improve this question
@dotty - It would help everyone if you could give this a title that is more applicable to your question. That said, what do you mean by "link some links to functions?" And when you say "it actually goes to do_action.php not the action within my plugin." what actions are you talking about, WordPress actions? Where to you want it to go? The more clear you can make the question the better we'll be able to answer. – MikeSchinkel Sep 1 '10 at 23:10
Voted question down because the title is so obscure and the question is unclear. I'll vote back up if the title and question are improved. – MikeSchinkel Sep 3 '10 at 3:14
Voted down because of the description. The title is pretty fitting but much too broad as well. – hakre Sep 4 '10 at 12:31
up vote 2 down vote accepted

Rather than include an HTML file, include a PHP file instead. Then, at the top of your PHP file you can check to see if any data's been submitted and process it before displaying the form. So instead of what you have, try:

function show_hotel_dashboard(){
    include 'dashboard.php';

Then on the page do things like:

<a href="dashboard.php?action=do_something">Do something</a>

And in your dashboard.php file, start with

if($_POST["action"] == "do_something") {

    // Do something

} else {

    // Output your regular dashboard page

} ?>
share|improve this answer
This seems like a better way to do it rather than using wp_ajax and jQuery. – dotty Sep 2 '10 at 15:13
You might also want to review the Codex articles about creating options pages, particularly this one - codex.wordpress.org/… ... it provides a concrete example of how to retrieve/act on $_POST data before doing anything with the UI. – EAMann Sep 2 '10 at 15:29

May I suggest that you take a look at my WordPress Plugin Template Creator :)

share|improve this answer

Your Answer


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.