Solved

Wordpress plugin sub menu issue

Posted on 2015-01-19
1
89 Views
Last Modified: 2015-02-27
Hi,

I'm creating a wordpress plugin and I'm stuck on something that I just can't figure out.

I have the following method which creates the plugin menu.

function nl_create_menu() {
    add_menu_page('National Locums Timesheets','Timesheets','administrator',__FILE__,'nl_ts_admin');
    add_submenu_page(__FILE__, 'National Locums Timesheet Import','Import','administrator',__FILE__.'&act=nl_ts_import','nl_ts_import');
}

Open in new window


I then have two methods define to handle each link;

function nl_ts_import() {
    echo 'import';

    // Include view
    include_once __NL_TIMESHEET_PLUGIN_PATH . 'view/admin_import.view.php';
}

function nl_ts_admin() {
    echo 'Admin index';
}

Open in new window


The problem I'm having is that clicking the Import link in the sub menu doesn't load the 'nl_ts_import' function, it's called the nl_ts_admin function instead.

I'm sure it's a really simple thing to fix, but I cannot figure out where I'm going wrong.
0
Comment
Question by:SheppardDigital
1 Comment
 

Accepted Solution

by:
SheppardDigital earned 0 total points
ID: 40635076
I managed to resolve this my changing the code that created the link.

function nl_create_menu() {
    add_menu_page('National Locums Timesheets','Timesheets','administrator',__FILE__,'nl_ts_admin2');
    add_submenu_page(__FILE__, 'National Locums Timesheet Import','Import','administrator',__FILE__.'_nl_ts_import','nl_ts_import');
    add_submenu_page(__FILE__, 'National Locums Discipline Targets','Discipline Targets','administrator',__FILE__.'_nl_ts_targets','nl_ts_targets');
    add_submenu_page(__FILE__, 'National Locums Discipline Months','Months','administrator',__FILE__.'_nl_ts_months','nl_ts_months');
    add_submenu_page(__FILE__, 'National Locums Discipline Data Editor','Data Editor','administrator',__FILE__.'_nl_ts_data_editor','nl_ts_data_editor');
}

Open in new window

0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

How to create your own WordPress Theme Before I begin with the theme design tutorial, I would like to give you the basics of what is required to make a WordPress Theme. The most basic WordPress theme only requires 2 files: a style.css file and an…
Wordpress Horizontal Drop-Down Menu In this tutorial I will show you had to add a WordPress horizontal navigation menu to your theme. I have searched and searched for a good tutorial on creating a WordPress nav menu without adding a plug-in or us…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question