I'm trying to add sections and fields to a new settings page i WordPress. But I get the response "Call to undefined function add_settings_section()...". Does anybody know why that is? This is the code in question: add_settings_section( 'ac_div', 'Inställningar', 'ac_section_text', 'Anders-counter' );

add_settings_field( 'diven', 'För in mätarställningen här', 'ac_add_field', 'Anders-counter', 'ac_div'); 

Thankful for help. Anders

1 Answer

add_settings_field function located under wp-admin/includes/template.php

you can load that file before calling add_settings_field, or simply add your code under admin_init hook

add_action('admin_init', 'your_function'); function your_function(){ add_settings_field( 'diven', 'För in mätarställningen här', 'ac_add_field', 'Anders-counter', 'ac_div' ); } 

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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.