0

I've created a custom options page and referenced it through my functions.php file. When i do this, the Pages option is removed from the WP dashboard, almost as if overwritten by the new options page.

The pages continue to exist, and I can navigate directly to the new page editor, but I cannot access it via the menu in the dashboard.

This is my code, within fixtures.php

<?php
add_action( 'admin_menu', 'fixtures_menu' );

function fixtures_menu() {
add_menu_page( 'Fixtures Info', 'Fixtures Info', 'manage_options', 'fixtures-info', 'fixture_options', '../wp-content/themes/scrum-and-coke/img/infoicon.png', 20 );
}

add_action('admin_init', 'register_settings');

function register_settings() {
register_setting('settings-group','season');
}

function fixture_options()
{
?>
<div class="wrap">
    <h2>Fixtures Info</h2>

    <p>This information is used on the fixtures & result page.</p>

    <form method="post" action="options.php">

        <?php settings_fields( 'settings-group' ); ?>
        <?php do_settings_sections( 'settings-group' ); ?>

        <p><input type="submit" value="Save" class="button-primary" /></p>
        <fieldset style="border: 1px solid #ccc !important;padding: 10px !important;"><legend>Season information</legend>
            <p><strong>Name of season/premiership:</strong><br />
                <input type="text" name="season" size="45" value="<?php echo get_option('season'); ?>" />
            </p>
        </fieldset>
        </fieldset>
        <p><input type="submit" value="Save" class="button-primary" /></p>
    </form>
</div>
<?php } ?>

Which is then referenced in the functions.php file

require_once 'fixtures.php';

Any ideas why Pages is being overwritten/disappearing from the dashboard?

1 Answer 1

1

Look at the last argument to add_menu_page()-- $position.

$position
(integer) (optional) The position in the menu order this menu should appear. By default, if this parameter is omitted, the menu will appear at the bottom of the menu structure. The higher the number, the lower its position in the menu. WARNING: if two menu items use the same position attribute, one of the items may be overwritten so that only one item displays! Risk of conflict can be reduced by using decimal instead of integer values, e.g. 63.3 instead of 63 (Note: Use quotes in code, IE '63.3').

The position identifier you have chosen-- 20-- is the position of the "Pages" menu, which is therefore being overwritten.

Use 20.1 or similar as suggested by the Codex. At the very least, use an integer that isn't part of Core.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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