How to: add option to add more checkboxes on custom post type

Your question is very abstract. As far I understood you want some thing like categories. So for that adding metaboxes is not necessary. I think categories are enough. If categories are not full filling your need then make another custom taxonomy with ‘hierarchical’ => true,. I think it will serve your need. Also giving permissions … Read more

Adding labels to Setting titles with API

You need to pass last parameter $args, if you want add_settings_field to output <label> use `label_for’ argument, see code snippet below <?php add_settings_field( ‘my-id’, ‘Test Filed’, ‘mamaduka_test_field’, ‘general’, ‘my-section’, array( ‘label_for’ => ‘my-test-field’ ) ); ?>

wordpress settings api add fields

You’re passing the same ID to every single setting of a given type, rather than passing the $setting to the callback. Have a look at how I implement this type of callback in Oenology. function oenology_setting_callback( $option ) { $oenology_options = oenology_get_options(); $option_parameters = oenology_get_option_parameters(); $optionname = $option[‘name’]; $optiontitle = $option[‘title’]; $optiondescription = $option[‘description’]; $fieldtype … Read more

Plugin set default setting value when it activated

Your code will certainly use get_option() to retrieve the values for your options. get_option() accepts a second argument that allows you to specify a default. Use that instead of inserted values into the database unnecessarily. get_option( $option, $default ); If you are concerned about third party code, there is there is the option_{$option} filter that … Read more

Add custom content in user-edit.php page

Solved it by using show_user_profile and edit_user_profile instead: add_action( ‘show_user_profile’, ‘wpse_237901_user_edit_section’, 999 ); add_action( ‘edit_user_profile’, ‘wpse_237901_user_edit_section’, 999 ); function wpse_237901_user_edit_section() { # Code here… }

how can I detect that option value has changed?

I just came across your question while trying to do a similar thing. I figured out what I needed so I thought I would post an answer here in case someone else finds it useful. In short I used this filter: https://codex.wordpress.org/Plugin_API/Filter_Reference/pre_update_option_(option_name) And it looks something like this: function set_admin_notice_options( $new_value, $old_value ) { // … Read more

Settings API – how to update options manually?

That’s because your options are stored as a serialised array, in one row with name XX_theme_settings. To update one option, you would still need to retrieve the existing settings, ammend the appropriate value and update all options in your array together. For example: $my_options= get_option(‘XX_theme_settings’);//retrieve all options $my_options[‘XX_Option2’] = ‘my new value’; //amend value in … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)