1

Im making a custom plugin for wordpress and i need to create a page in the admin menu. I already have a file called mailing_list.php with the following code:

function jps_mail_list_page_entry() {
    add_menu_page(
        __('JPS Mailing List'),
        'JPS Mailing List',
        'manage_options',
        'jpsNews_mailinglist',
        'jpsNews_mailing_list',
        'dashicons-email'
    );
}
add_action('admin_menu', 'jps_mail_list_page_entry');


function jpsNews_mailing_list() {
    echo 'hello';
}

Now, in the plugin page i have this:

function jpsNews_activate_plugin() {
    include_once(plugin_dir_path(__FILE__).'pages/mailing-list.php');
}
register_activation_hook(__FILE__,'jpsNews_activate_plugin');

Its not working so, is it even possible to do it like this? how can i do it?

thanks in advance.

  • Try adding a sub page. – Cedon May 25 '17 at 18:55
0

found the problem. Turns out the function that creates the pages needs to be outside the activation hook. moved it to the end of the script and works perfectly.

Thanks =)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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