0

Hi i am new to wordpress plugin development. i have issues with settings api. please help if you can.

Below is my problem.

  function load_plugin() {

    add_settings_section('plugin_main', '<h1>Ticker Settings</h1>', 'plugin_section_text', 'plugin');
    add_settings_field('plugin_text_string', 'Title text', 'plugin_setting_string', 'plugin', 'plugin_main');
    add_settings_field('post_title_link', 'Link', 'plugin_link_setting', 'plugin', 'plugin_main');

    register_setting('plugin_options', 'plugin_options');
    register_setting('post_title_link', 'post_title_link');
}

function plugin_section_text() {
    echo '<p>Change your post ticker title and give link to.</p>';
}

function plugin_setting_string() {
    echo "<input id='plugin_text_string' name='plugin_options' size='40' type='text' value='" . get_option('plugin_options') . "' />";
}

function plugin_link_setting() {
    echo "<input id='post_title_link' name='post_title_link' size='40' type='text' value='" . get_option('post_title_link') . "' />";
}

add_action('admin_init', 'load_plugin');

function post_ticker_setting() {
    ?>
    <div class="wrap">
        <form action="options.php" method="post">
            <?php
            settings_fields('plugin_options');
            settings_fields('post_title_link');
            do_settings_sections('plugin');
            ?>
            <input name="Submit" type="submit" value="<?php esc_attr_e('Save Changes'); ?>" />
        </form>
    </div>
    <?php
}

This is the code. the problem i am facing is the last record which is link it is updating in database but the title text is not updating in database.

So please help me find solution. Thank you.

0

Change your id from plugin_text_string to plugin_options.

| improve this answer | |
  • thanks for replay first. i have changed id but still not working. – user2105662 Apr 2 '15 at 6:33
  • most of the time where ID are use there is a change of Conflict so i would suggest you to add a Prefix to you IDs like myIne_plugin_options Note: myIne is a Prefix goes in front of every ID you use, please try this, it might solve your issue. – tam Apr 2 '15 at 6:42
  • No it's not working still by changing ID, but if i am commenting the link code then it's working with the same code. Both combined not working. – user2105662 Apr 2 '15 at 7:13

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.