• After reading the WordPress tutorials on developing plugins I gave it a go and am building a Link Directory plugin which activates fine. I’m having trouble with the menu system though.

    My code:

    <?php
    /*
    Plugin Name: WP Link Directory
    Version: 1.0
    Plugin URI: http://www.idontexist.com
    Author: Dux0r
    Author URI: http://www.idontexist.com
    Description: A Links Directory for WordPress
    */
    
    register_activation_hook(__FILE__, 'wplinkdir_init');
    
    add_action('admin_menu', 'wplinkdir_menu');
    
    function wplinkdir_menu(){
    	add_menu_page('WP Link Directory', 'WP Link Directory', 8, __FILE__, 'wplinkdir_admin_page');
    	add_submenu_page(__FILE__, 'WP Link Directory','Main', 8, __FILE__, 'wplinkdir_main_page');
    	add_submenu_page(__FILE__, 'WP Link Directory - Categories','Categories', 8, __FILE__, 'wplinkdir_category_page');
    	add_submenu_page(__FILE__, 'WP Link Directory - Options','Options', 8, '__FILE__', 'wplinkdir_options_page');
    }
    
    function wplinkdir_admin_page(){
    	echo 'I am some content.<br />';
    }
    
    function wplinkdir_main_page(){
    	echo 'This is the MAIN page.';
    }
    
    function wplinkdir_options_page(){
    	echo 'This is the options page.';
    }
    
    function wplinkdir_category_page(){
    	echo 'I\'m test text for the category page.';
    }
    
    function wplinkdir_init(){
    	global $wpdb;
    	// some mysql functions are performed here
    }
    
    ?>

    The script runs the init function fine and creates some new tables. The top level menu (WP Links Directory) is created and displayed as are the three Sub Menus. The problem is that Main and Categories menus both display ‘I am some content.’ instead of their respective functions, and I don’t know why.

    What am I missing?

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Having Trouble Adding Menus’ is closed to new replies.