• * Register and add settings
         */
        public function page_init()
        {
            register_setting(
                'my_option_group', // Option group
                'my_option_name', // Option name
                array( $this, 'sanitize' ) // Sanitize
            );
    
            add_settings_section(
                'setting_section_id', // ID
                'My Custom Settings', // Title
                array( $this, 'print_section_info' ), // Callback
                'my-setting-admin' // Page
            );  
    
            add_settings_field(
                'id_number', // ID
                'Amazon Affiliate', // Title
                array( $this, 'id_number_callback' ), // Callback
                'my-setting-admin', // Page
                'setting_section_id' // Section
            );      
    
            add_settings_field(
                'id_number',
                'Amazon Access',
                array( $this, 'id_number_callback' ),
                'my-setting-admin',
                'setting_section_id'
            );  
    
    	add_settings_field(
                'title',
                'Amazon secret',
                array( $this, 'title_callback' ),
                'my-setting-admin',
                'setting_section_id'
            );
    
        }

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    I have wrote the above code but it is only displaying Amazon access and secret on my screen not the affiliate field.
    How do I correct this please?
    How do I pass the variable to my amazonapi.php code?

Viewing 1 replies (of 1 total)
  • The ID must be unique for each field in your code you used the same ID for Amazon Affiliate Amazon and Access, then WordPress is taking into account only the last (Amazon Access).

    The ID is the first value of the array in your case is “id_number”. Write a fix that will work.

Viewing 1 replies (of 1 total)
  • The topic ‘Forms and Menus’ is closed to new replies.