settings api store multiple array

I put this in the form so it knows its editting: <form method=”post” action=”options.php”> <?php settings_fields(‘venues_section’); ?> <input type=”hidden” name=”editmode” value=”<?php echo $editmode; ?>” /> <input type=”hidden” name=”venue_id” value=”<?php echo $venue_id; ?>” /> <?php submit_button(); ?> </form> The receiving validation function can then handle that by doing something like this: function venues_validation_callback($input){ $venues = get_option(‘venues’); … Read more

WordPress setting API strucked

You are Missing few Things. First of all hook the function wpt_theme_init with admin_init or similar one. otherwise your function will not execute. example below add_action( ‘admin_init’, ‘wpt_theme_init’ ); add_settings_section and add_settings_field take 4th argument as a $page parameter. which is wptsettings in your case. remember? you have named your page wptsettings in add_theme_page ( … Read more

Settings API enable default settings on theme install?

You can pass defaults to get_option. The second parameter is a fallback. $default (mixed) (optional) The default value to return if no value is returned (ie. the option is not in the database). Default: false So, for example, instead of: $options = get_option(‘plugin_options’); You’d want: $options = get_option(‘plugin_options’,array(‘display_sidebar’ => true)); Or you can insert your … Read more

Single callback with multiple setting fields

add_settings_field() accepts six arguments, the last one is an array of arguments: add_settings_field($id, $title, $callback, $page, $section, $args); You can add custom values here, so you can reuse one callback. A simple example: add_settings_field( ‘foo’, ‘Foo’, ‘wpse_settingsfield_callback’, ‘my_page’, ‘my_section’, array ( ‘context’ => ‘foo’ ) // custom arguments ); add_settings_field( ‘bar’, ‘Bar’, ‘wpse_settingsfield_callback’, ‘my_page’, ‘my_section’, … Read more

Setting the uploads directory

You can use the ‘upload_dir’ filter add_filter(‘upload_dir’, ‘set_upload_folder’, 999); function set_upload_folder( $upload_data ) { // absolute dir path, must be writable by wordpress $upload_data[‘basedir’] = trailingslashit(ABSPATH). ‘/files’; $upload_data[‘baseurl’] = ‘http://subdomain.wptest.com/files’; $subdir = $upload_data[‘subdir’]; $upload_data[‘path’] = $upload_data[‘basedir’] . $subdir; $upload_data[‘url’] = $upload_data[‘baseurl’] . $subdir; return wp_parse_args($upload_data, $upload_data); } This code will works no matter if year/month … Read more

check for the current screen

Those variables and functions only exist in the admin area, and aren’t for frontend use. You will need to use a different mechanism for the frontend. Additionally: the docs say that you have to call this after the admin_init hook, calling on that hook will always return null the function is not loaded on all … Read more

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