Why does get_theme_mod return blank (or default value) but get_option returns saved value?

This is original code from wordpress: function get_theme_mods() { $theme_slug = get_option(‘stylesheet’); $mods = get_option(“theme_mods_$theme_slug”); if (false === $mods) { $theme_name = get_option(‘current_theme’); if (false === $theme_name) $theme_name = wp_get_theme()->get(‘Name’); $mods = get_option(“mods_$theme_name”); // Deprecated location. if (is_admin() && false !== $mods) { update_option(“theme_mods_$theme_slug”, $mods); delete_option(“mods_$theme_name”); } } return $mods; } function get_theme_mods() { $theme_slug … Read more

checkbox with get_option not working

Full code to add settings page with checkbox option. You don’t need loops and something else. WordPress will make everything for you. Get more info in Codex function wpse_319648_render_popup() { $options = get_option(‘wpse_319648_checkbox’); $default = isset($options[‘popup’]) ? $options[‘popup’] : 0; printf( ‘<input type=”checkbox” name=”%1$s[popup]” value=”1″ %2$s>’, ‘wpse_319648_checkbox’, checked($default, 1, false) ); } function wpse_319648_settings_page() { … Read more

How to Edit the Order of Global Colors in Elementor? [closed]

The solution I’ve come up with: This can be done from within the database. You will want to look for _elementor_page_settings inside the wp_postmeta table. The meta_value will be serialized data, so save a copy of the _elementor_page_settings data before making an edit. In your data, say you have the following: {{i:0;a:3:{s:3:”_id”;s:7:”de51da3″;s:5:”title”;s:6:”Blue 2″;s:5:”color”;s:7:”#123456″;} i:1;a:3:{s:3:”_id”;s:7:”de51da3″;s:5:”title”;s:6:”Blue 3″;s:5:”color”;s:7:”#123456″;} … Read more

How to save values of a custom input field on the Network > Site Info screen

The problem was a redirect in site-info.php. After that the $_POST variable was empty in the code inserting in the admin_footer. I just need to use a further hook ‘admin_init’ and save the value here. add_action(‘admin_init’, ‘pg_save_custom_site_options’); function pg_save_custom_site_options(){ global $pagenow; if( ‘site-info.php’ == $pagenow && isset($_REQUEST[‘action’]) && ‘update-site’ == $_REQUEST[‘action’] ) { // Use … Read more

Settings API erases itself?

The reason is that if you are on page 1, the data that is posted to be saved is an array of the form: XX_theme_settings=array(‘XX_Option1′ =>’input1′,’XX_Option2’=>’input2′,…) and contains no data from page 2. This is because the input from page 2 is not posted with it (since it wasn’t in the same <form> – it’s … Read more

Why won’t register_setting() create a setting?

I am not exactly sure what you mean by saying that you can see your settings section and fields displayed correctly, but your my_plugin_settings has not been created. I know sometimes I forget to add the actual admin part in which generally looks something like this: settings_fields( ‘my_plugin_settings’ ); do_settings_sections( ‘my_plugin_settings’ ); submit_button(); Or is … Read more

Add custom meta box on Post page

You need to use the add_meta_box function add_action( ‘add_meta_boxes’, ‘my_custom_meta_box’ ) ); function my_custom_meta_box(){ $args = array(); add_meta_box( ‘my_metabox_id’, __( ‘My Meta Box’, ‘my_textdomain’ ), // Title ‘my_callback_function’, // Callback function that renders the content of the meta box ‘post’, // Admin page (or post type) to show the meta box on ‘side’, // Context … Read more

possible to make sections in theme customizer sortable and saveable at publish button clicked?

Simple tutorial – How to sort customizer sections in the panel and add order to theme. 1. You must use prefixes to do this because customizer don’t support custom classes. ctmss_panel_ – for panels ctmss_section_ – for sections ctmss_hidden_ – for hidden sections that has a input with values 2. Add panel to the Customizer … Read more

Set default options for inserting media

You can do this in two ways. If you want to keep it theme specific, edit your functions.php file with this code: add_action( ‘after_setup_theme’, ‘my_new_default_image_settings’ ); function my_new_default_image_settings() { update_option( ‘image_default_align’, ‘right’ ); update_option( ‘image_default_link_type’, ‘file’ ); } The other way to do it is more general, but also more rigid: Go to YOURSITE.COM/wp-admin/options.php Find … Read more

In Settings>>General I am missing some fields

You are in the wrong settings page. Your site is a multi-site setup; the URL is set in the site manager, not in individual sites. Go to Network Admin/Sites in the My Sites menu: Select a site to edit: Change the URL: Update You need a subdomain setup to get editable URLs. See Create A … Read more

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