Questions tagged [options]
In WP `options` is the term used for variables stored in the database. They are accessed through the options API.
1,052
questions
2
votes
2
answers
23
views
Does WordPress automatically redirect to the URL specified in settings?
My WordPress site used to require htaccess rewrite rules to redirect non-www to www (or vice versa) and http to https. Without those rules, the site would be accessible at whatever URL the user ...
0
votes
1
answer
27
views
Theme / Divi change visitor css and site logo and all site urls based on REQUEST_URI non logged in wp user
I am trying to store the baseurl to options table in wordpress for non logged in users. Basically if the user was referred to url mysite.com/go/affilatename I want to store affilatename (baseurl) to ...
0
votes
1
answer
61
views
Add "/blog/" as base for all blog post URL
I want to add /blog/ as base for all blog post URLs on my website. Only issue is, I already have a page with the permalink as /blog/. So now the permalink settings are not allowing me to update as /...
0
votes
1
answer
16
views
What is the equivalent of get_user_option for saving options?
In a custom plugin, I want to save user interface settings (e.g. which sections are expanded/hidden).
From what I see, the get_user_option (docs here) function is perfect for retrieving the value.
...
0
votes
0
answers
107
views
How to disable the PDF preview in the file block by default
when I insert a PDF file with the file block on the page it always opens to me with the preview of the file with the pdf viewer, so I have to put the check to disable it. Is there a way to have that ...
0
votes
0
answers
13
views
Multiple plugins settings of same developer into ONE settings page linked together
Im quite new to wordpress and plugins.
I'm still a student so im still in the learning curve.
Thank you in advance for reading my question
CONTEXT
Each plugin is a plugin on its own but made by the ...
0
votes
1
answer
169
views
How to figure out correct wp_options to have autoload='yes'
I have a website that has suddenly become slow. I don't know what caused the change. I haven't installed new plugins, and I don't think I recently updated any plugins. Upon inspection with Query ...
0
votes
0
answers
60
views
move setting data from wordpress api to codestar freamwork
I am coding a plugin that uses the Star code framework
It should be mentioned that I had written this plugin using WordPress API before. Now I want to integrate and make it more advanced, but I ran ...
0
votes
1
answer
48
views
Settings API not Saving to Database or Display
I am developing a payments gateway, and wanted to have a page with a form to save authentication credentials for reaching out to an external API used for payment. I made a settings page using ...
0
votes
0
answers
41
views
Admin Message after Plugin Option Updated
In my plugin, I want to display a specific message when a plugin option is changed. The Codex indicates that I can use the 'updated_option' filter this way:
// settings changed notices
add_filter('...
0
votes
0
answers
43
views
How to add custom settings to the menu of custom post types?
Not sure if this has been asked before. But how can we add custom settings to the menu of custom post types? Or add custom fields for an entire post type and you can edit them? For example:
This is ...
0
votes
0
answers
41
views
Dynamic Email Handler with 'header ("Location: ...'
hope you are well!
Description
I am coding a theme to reuse with clients. However, I am trying to avoid showing my clients' email on their websites and like to use a dynamic email-handler.php ...
0
votes
0
answers
103
views
save array of objects with update_option
How do I save an array of objects in Wordpress/PHP via update_option ?
What I'm trying to save is something like:
update_option('my_option', [
{
'c': htmlspecialchars($_POST['hidden_category']),
...
0
votes
1
answer
34
views
How to access values from your own settings page in javascript?
I added may own settings page for my plugin with php. Furthermore I need to access the values from two inputFields from the settings page after someone clicks on a submit button on the public page. My ...
0
votes
0
answers
26
views
Neither update_option nor delete_option fires in deactivation hook
I have a plugin. And the following code:
function activate_my_plugin(){
// my_option value here: 1
update_option('my_option',0,true); // I've tried with and without last parameter
// ...
0
votes
0
answers
208
views
Color Picker UI in admin is not correct
I need to have color picker settings filed in my plugin. I have registered a field and its saving value in the database correctly. But, in the admin area the picker user interface is not correct I ...
0
votes
1
answer
22
views
Change in one place the data about the company, which are placed on several pages [closed]
Some pages of the site contain information about the company. If something changes, then you need to change everything manually. Is there a way to change the data in one place and it will change ...
2
votes
0
answers
840
views
Add a custom WooCommerce settings tab with sections [closed]
I'm trying to add a custom settings tab to the WooCommerce settings screen. Basically I want to achieve a similar thing to the Products settings tab, with the subsections/subtabs:
I haven't been able ...
2
votes
2
answers
55
views
How to show every second user different types of banners?
I have to create the next feature fore the project:
We have two type of top-bar lines. We need to show every second user(or user session I think it's more easy) different types of banners. Okay I ...
0
votes
1
answer
71
views
Serving Images from subdomain in wordpress
This is my current image url
https://example.com/wp-content/uploads/2022/06/sample.png served via cloudflare
uploads folder is in my wordpress installation
I am syncing the uploads folder to Backblaze ...
0
votes
1
answer
22
views
wp_options not returning value for logged out users?
I have saved my custom plugin settings inside wp_options table, but when I try to access them using "get_option" function it returns me undefined for logout users, but when I logged in it ...
1
vote
1
answer
54
views
save_post_{CPT} not updating the 'sticky_posts' option
add_action( "save_post_{CPT}", 'update_sticky', 15, 1 );
function update_sticky( $post_id ) {
$stickies = get_option( 'sticky_posts' );
if ( ! in_array( $post_id, $stickies ) ) {
...
1
vote
0
answers
42
views
How to get specific setting by settings_fields()?
I am working on a plugin and on the settings page I have 2 settings
and I want to show Only one setting "backgroundColor" so how should i do that?
This is the code:
<form action="...
0
votes
2
answers
1k
views
Check if an option exists and get its value in one hit
I have an option admins_settings that has an array of sub-options that is stored in the wp_options table. Before I get its value from the table, I check if this field exists by running this code:
if ( ...
0
votes
0
answers
29
views
get_site_option / update_site_option - the main site and sub sites do not share the same storage
get_site_option / update_site_option is supposed to get / update an option for the current network (contrary to its name).
I have noticed that it works only for sub-sites, all sub-sites share the same ...
1
vote
1
answer
640
views
The Settings API - What is the purpose of default value in register_setting?
I'm trying to wrap my head around the Settings and Options APIs as I'm writing a simple plugin.
One thing that has really stomped me is the possibility to add a default value to an option when calling ...
1
vote
1
answer
318
views
How to get bool with `get_option()` when already registered setting with type `boolean`
When I register a boolean setting using register_setting() I already pass the data type:
register_setting(
option_group: '…',
option_name: '…',
args: [
...
0
votes
0
answers
259
views
get_option() and update_option() in a transaction (for an autoincrement value)
I need an autoincremented ID for a custom post type to manage order IDs. For this, I would use the WP Options API, but I'm afraid of a typical transaction issue:
$count = get_option('my_id');
...
1
vote
0
answers
73
views
Settings API not saving values to database
Here is what I'm attempting to do:
I have two fields called Client ID and Client Secret.
I would like to save each individual item in the database as the following keys: instagram_client_id and ...
0
votes
1
answer
10
views
How does one update complex options?
I'm using Tom McFarlin's WordPress-Plugin-Boilerplate along with JoeSz's Tutorial.
I'm loading in a complex options item using
$options = get_option($this->plugin_name);
This works fine for the ...
0
votes
1
answer
14
views
How to change color of a word in text after WP update
Since the latest WP update it changed my setting. Normally I had a ''change text color'' setting in the red area (see screenshot). Anyone can guide me how to add the option in this field?
0
votes
1
answer
43
views
Elementor - Edit Global Colors Order
I'm trying to change the order of the Elementor global colors list.
This question was originally posted here, and while the instructions are thorough, I can't find the elementor_page_settings in the ...
0
votes
1
answer
25
views
display category name based on its equivalent id
I have a theme with options. I would like to display 3 posts for a specific woocommerce category, I could show category id and I don't know how to display products based on its category id, but I have ...
0
votes
1
answer
137
views
Native timestamp on wp_options option
Does anyone know if the wp_options table have modified timestamps for their options? I have an option that has an object as the option value as shown below:
The "Access Token" within the ...
0
votes
0
answers
187
views
Managing and deleting transients with dynamically generated transient names
Let's say I have access to a remote API that stores car data, and I want to be able to place car information box(es) into posts using a shortcode. The shortcode fetches JSON data with wp_remote_get() ...
0
votes
1
answer
76
views
Multisite Equivalent of `register_setting`?
Working on converting a custom plugin to run in multisite. I want the settings to apply globally, not per-site. I've converted all of the get_option calls to get_site_option and the equivalent for ...
0
votes
1
answer
172
views
How to Edit the Order of Global Colors in Elementor? [closed]
I looked all over for a solution to changing the order of the global colors in Elementor, but didn't find one. People have asked how to do this both in Elementor's forum as well as reddit and a few ...
1
vote
1
answer
947
views
How to set Gutenberg preferences programmatically with wp.data.dispatch?
The Gutenberg Options > Preferences menu contains a number of additional settings to customise the Gutenberg experience. The default GUI is shown below. I would like to programmatically enable the ...
0
votes
0
answers
17
views
What is the XSSAttack option_name for in the options table?
I am working on eliminating malware from a site and reviewed the entries in the options table. Found an "option_name" of XSSAttack with an "option_value" of 1.
Lots of searches on ...
1
vote
1
answer
96
views
SQL QUERY - Select a value directly from the database
In my WordPress database, in the options table, there is a field in the option_name column which is called titb_flc_options, whose value is this:
s:397:"a:10:{
s:16:"69c3d01e88aba503&...
0
votes
0
answers
27
views
Using shortcodes in the Site Title
I'm using MetaBox for a settings page with custom fields. I'd love to be able to use their shortcode to pull custom fields into and used as the Site Title.
Does anyone have any ideas on how this or ...
0
votes
0
answers
54
views
how to show new field if option selected?
I have this code for create setting page for my plugin.
with this code , i show two field in plugin setting for change style and set shadow on/off.
In style section i have 4 option and i want show new ...
0
votes
2
answers
69
views
Gathering and logging data from a plugin: how to do it without race conditions?
I have a need to capture data in a WordPress plugin and append it into some sort of log.
The data I want happens to be slow SQL queries from $wpdb->queries. I'm hoping to present useful "...
0
votes
0
answers
430
views
wp option get blogname --url=my-sub-site.com returning main site option
I have a multisite setup with some 14 woocommerce sites.
site_id | domain
1 | local.mainsite.com
2 | local.subsite-2.com
3 | local.subsite-3.com
4 | local.subsite-4.com
I want ...
0
votes
1
answer
362
views
Option value not get saved in the database
I'm trying to put up a simple plugin, but this Settings API doesn't give me a break.
I have one field registered in the settings page, but the values we enter don't get saved to the database.
Here is ...
1
vote
1
answer
231
views
What is the function to get options of the parent site of a multisite network?
I need to set options of a specific plugin at the parent site of a network and use those settings globally to override each site, unless set to false.
Neither get_option() or get_site_option() does ...
0
votes
1
answer
208
views
Save default options as an array of options and display in REST API
I am trying to save array of options and display them in the rest api.
I know I can store the options one by one with register_setting, but I think saving all the options in an array is better than ...
1
vote
1
answer
411
views
Settings API - sanitize_callback is not called and it leads to an incorrect behavior
I am in the process of creating some options / the options page for my plugin.
In the context of this I have only added two checkboxes so far to store boolean values. The creation, display on the page ...
0
votes
1
answer
72
views
Call require_once form admin page with checkbox
I'm creating a custom WP plugin. Inside my main plugin file (functions.php) I've includes the following line of code so a second file (module_2.php) with additional code will be loaded:
define( '...
0
votes
0
answers
151
views
Problem with MEMCACHE and Redis with wp_options
I have developed a plugin for worpress but it is giving me problems when I start MEMCACHE o REDIS CACHE.
I have been told that the problem is that I am using wp_options directly and that I should ...