Questions tagged [options]
In WP `options` is the term used for variables stored in the database. They are accessed through the options API.
1,043
questions
1
vote
1
answer
31
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
15
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
25
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
13
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 ...
0
votes
0
answers
13
views
Wordpress Select Option Load Custom Fields
I created a new post type called "Programs" and i created custom fields on Programs width Advanced Custom Fields plugin. I want to compare the Programs fields with each other on the page ...
0
votes
0
answers
24
views
Add multiple checkboxes as single field to Custom Shipping Method Settings Page
This is my first WP plugin. And I have been able to get it working perfectly with the settings page and also showing the shipping method on the checkout page. On a requested feature I need to have ...
0
votes
0
answers
9
views
Drop Down options aren't saving in my wordpress plugin options page
So, I'm developing a plugin. I have an options page with tabs, and so far so good. The text and text area settings are working OK, but the drop down options aren't saving. For reasons I don't know. ...
0
votes
0
answers
12
views
Autopopulate a value
I created an options page where users can enter their Google Captcha key and secret. Using update_option I am able to add these values to Elementor's settings.
I'm trying to do the same with JetForm ...
1
vote
1
answer
31
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 ...
0
votes
0
answers
20
views
How to save Setting pages data to the database?
I have created a setting page and I have a basic form in there I want to save its data in the database how can I achieve that.
This is the HTML form:
<label class=""><?php _e('...
1
vote
1
answer
33
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
26
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
60
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
9
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
6
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
18
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
0
answers
12
views
Save log for imports in WordPress database - options-table, custom post type or other place?
I have a couple of custom imports, where I would like to save some log-information in the database, after they've completed, such as:
How many lines was imported.
DateTime for when it ran.
URL that ...
0
votes
0
answers
31
views
Use Acf Repeater data as options for a different acf custom select field
I want to create 2 ACF custom fields. One to store a list of data and another custom field to act as a Select Dropdown and use the first ACF custom field as options.
Is this possible? I tried ...
0
votes
1
answer
23
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
27
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
37
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
0
answers
20
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
82
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
158
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
9
views
Post page overwrite the custom blog page
is there any chance to stop wordpress to overwrite the custom blog page
0
votes
0
answers
16
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 ...
0
votes
0
answers
11
views
WP Optimization: Overwriting options to autoload=yes for often used options?
I'm currently trying to optimize my WP-page.
I checked with "Query Monitor" and I see a lot of options which are fetched on every pageload (not a huge runtime cumulated, but still ~15-20 ...
1
vote
1
answer
42
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
20
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
19
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
0
answers
32
views
Set all WooCommerce Products to Simple, Virtual & Downloadable
I want so set my all products of my WooCommerce store to Simple -> Virtual and Downloadable Programmitacly.
And hide all the Unwanted tabs & fields like shipping, Inventory, etc.
0
votes
2
answers
50
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
99
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
18
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
57
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
58
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
117
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
0
answers
23
views
Metabox repeatable fields with select options
In my dashboard admin, I have two metaboxes with repeatable fields in the same page. The first metabox has only one input value $field[tag_filter]. The second metabox has a select tag to display ...
0
votes
0
answers
99
views
How to set WordPress timezone in functions.php?
I'm making an ACF options page and trying to add a timezone setting there, so I don't need to expose the actual WordPress settings page to user. I've been trying to find a function to change the ...
0
votes
1
answer
67
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
64
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 ...
0
votes
1
answer
45
views
Add description to custom plugin setting
Using add_settings_field(); i am able to add my custom setting:
add_settings_field('AUTOPLAY', 'Auto Play', 'printAutoPlayCheckbox', 'my_settings');
function printAutoPlayCheckbox()
{
$id = '...
0
votes
1
answer
17
views
Save Plugin Options as Array
I am trying to create a simple option page. The options consist of a text field per user role. But I don't want to edit the code every time I add a new user role.
So I am trying to "for each"...
1
vote
1
answer
42
views
update a value in wp_options [closed]
This seams to be basic -but I don't get it.
If I query an option with get_option I get the string:
[{\"title\":\"Brand Primary\",\"value\":\"#2185D0\",\"...
0
votes
0
answers
469
views
Retrieve my custom settings in the settings/ API endpoint
I did read this post: Serialized settings in rest api and while I am actually convinced the answer is what I need, I cannot make it work.
What I am trying to achieve is to get my own settings ...
2
votes
1
answer
178
views
Which WordPress option stores the current active theme?
I always thought that the current theme is saved under the "template" option.
But looking inside the "secret" /wp-admin/options.php area, I see other related options.
In total, ...
2
votes
0
answers
36
views
Custom widget select options needs to stay selected after save
I am working on a custom widget that includes a select options drop-down list of pages. When I select a page and save, the selected option does not stay selected. However, if I refresh the widgets ...
0
votes
0
answers
178
views
Whats the best practise on how to store json data from a custom settings page?
I'm creating my first Wordpress Plugin and want to let the user configure multiple urls which he can name and safe as "channels".
I've set up a settings page and wanted to store the data ...
1
vote
1
answer
509
views
What are Attributes used for in a Wordpress Multisite?
When you edit a Wordpress Multisite, there is this section of Attributes with multicheckboxes to select from, just curious what this actually does (if anything). I never needed to check "Public&...
0
votes
0
answers
47
views
Creating an array from form inputs before it is posted to the options database
I am creating a plugin and I want to be able to have the user input a starting number and ending number from an options page. When they submit it I want to create an array of the numbers (example ...