• Resolved HorrorUK

    (@horroruk)


    I’m trying to create an admin options page, but I’m getting a syntax error report, but I don’t see how it is a problem.

    So, I’m hoping one of you whizzes will see the problem 🙂

    I’ve taken the code from the Codex:
    http://codex.wordpress.org/Adding_Administration_Menus

    The line that seems to be causing the problem is this one:

    function mt_add_pages() {

    I say that because removing the line removes the error.

    This is the code I’m using, including that line, and it tells me the error is on the closing of the PHP at the end.

    <?php
    // Hook for adding admin menus
    add_action('admin_menu', 'mt_add_pages');
    
    // action function for above hook
    function mt_add_pages() {
    
    // Add a new submenu under Settings:
        add_options_page(__('Test Settings','menu-test'), __('Test Settings','menu-test'), 'manage_options', 'testsettings', 'mt_settings_page');
    
    // mt_settings_page() displays the page content for the Test settings submenu
    function mt_settings_page() {
        echo "<h2>" . __( 'Test Settings', 'menu-test' ) . "</h2>";
    }
    ?>

    I’m trying to create a menu item under the settings menu in admin.

    Thanks.

Viewing 1 replies (of 1 total)
  • Thread Starter HorrorUK

    (@horroruk)

    🙂 I found the solution:

    <?php
    // Hook for adding admin menus
    add_action('admin_menu', 'mt_add_pages');
    
    // action function for above hook
    function mt_add_pages() {
    
    // Add a new submenu under Settings:
        add_options_page(__('Test Settings','menu-test'), __('Test Settings','menu-test'), 'manage_options', 'testsettings', 'mt_settings_page');
    
    } // Add this closing bracket
    
    // mt_settings_page() displays the page content for the Test settings submenu
    function mt_settings_page() {
        echo "<h2>" . __( 'Test Settings', 'menu-test' ) . "</h2>";
    }
    ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Error in code, but I don't see where’ is closed to new replies.