Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [variables]

A variable is a storage location and an associated symbolic name (an identifier) which contains some known or unknown quantity or information, a value. The variable name is the usual way to reference the stored value; this separation of name and content allows the name to be used independently of the exact information it represents.

1
vote
1answer
384 views

MySQL variable in query

I've got tenant portal when I need to show running balance for each transaction. Here's query I've written which does what I need it to do. Problem I've got is that it doesn't work in Wordpress. Here'...
1
vote
1answer
509 views

How to put a variable in a instance in the widget

I am creating a widget that handles order numbers. The basic structure is as follow: // pretty generic widget functions public function widget($args, $instance) { $order_number = $instance['...
0
votes
1answer
9 views

saving variables after redirect

Is there a way to save a variable after you redirect to another page. For example... I want to save the password submitted from my form into the variable $temp_passkey, and be able to access it on the ...
0
votes
1answer
457 views

Woocommerce image variation not changing

I have Design and size variations of a product and have uploaded the various images accordingly. On the front end, the images are swapping when the user selects different Design and size. The ...
0
votes
1answer
1k views

WooCommerce quantity box for each variation

I'm trying to display a quantity box next to each of my product variations in the main shop page. I have t-shirts listed in different colors and sizes and sell B2B. I therefore need the quantity ...
0
votes
1answer
68 views

How to make url variable?

I just want to know how can I make variables on my wordpress link? so can I make get function on my page. Example I have url page www.example.com?page=123 and add some variable like mobile number. ...
0
votes
1answer
346 views

Redirect users in first login to a dynamic link

I'm using a Gravity Forms user registration to handle registration processes, and I use Gravity Forms custom post type + wp resume manager to let the user submit some fields in his resume within the ...
0
votes
1answer
494 views

PHP, Creating a dynamic variable

Is there any way through which I can declare the dynamic variable in php. for eg, I am using a for loop and the variable name is $message. and I want to add some dynamic data at the end of the ...
0
votes
1answer
271 views

Passing parameter from the current URL to redirect to another url

I have a search results page and on the page, I would like to be able to filter by category. So when the user searches an item, it gets passed to the results page in the url like: website.com/?s=...
0
votes
1answer
240 views

Not getting input from get_query_var

I want to pass on values from a search field and use those values to show posts with specific tags. I'm using get_query_var for this. I'm almost there, but not getting the values in my query. When I ...
0
votes
1answer
4k views

How to insert current user ID in a shortcode?

I have a shortcode from a plug-in called Pods that is used like [pods-form name="user" id="" fields="my_field, my_field_2, my_field_3"] Parameter name contains the name of the custom post type (...
0
votes
1answer
382 views

Excluding pages in WP_query using ACF

I have a custom loop for showing child pages of the current page, but I'd like to allow the WP user to enter page IDs to be excluded from the loop, using Advanced Custom Fields. My current loop is as ...
0
votes
1answer
33 views

Add array of category IDs to global variable?

I'm wondering how I can add a global variable containing an array of category IDs. On my site, I have menus and custom loops and every time I want to delete a category of them, I have to access each ...
0
votes
1answer
115 views

Use a select box to change a php variable

I am currently stuck on a little problem. I'm using a localStored value to differentiate the content that user sees depending on their choice. <div class="form-group form-inline hidden-print"> ...
0
votes
1answer
106 views

Child theme functions.php file change database entries

I'm sure my title is not the correct terminology. I will do my best to explain what I'm trying to accomplish. Years ago I spent countless hours customizing a theme. I was finally forced to update ...
0
votes
1answer
29 views

require happens out of order

I have a page template that is including another file via require_once. I want this included file to have access to the $post object but it can't find it. So I ran something like this to see what's ...
0
votes
1answer
37 views

How to get variable from function.php to loop file

i had code in function.php file : $selective = new WP_Query($args_selective); get_template_part( $loopFile ); i cant get $seletive in my loop file. Help me pls. Thanks for any answer !
0
votes
1answer
119 views

Editing Global Variables from Inside Functions

I'm working on my first plugin and I have two separate functions inside to accomplish two different task. Each function is added to a different hook, one using actions and the other using filters. ...
0
votes
1answer
41 views

Class variables in shortcodes

Don't know what I'm doing wrong but, I have the following code: class the_shortcode { //Define Class Variables private $var; public function __construct() { ...
0
votes
1answer
502 views

Adding to an array & passing it through do_action/apply_filters

For exercise I am working through a PHP class to add meta boxes I found on GitHub. I just copied the code and now I am playing around with it to understand it. It works like this: The file ...
0
votes
1answer
136 views

Can I get variable into dynamic sidebar?

How can I get a variable into a sidebar? $sidebarnum = 4; dynamic_sidebar('Footer Widget $sidebarnum'); ?>`
3
votes
0answers
621 views

Setting Cookie Using a Variable from the URL

I need to hand code an affiliate link (we do not want to use an existing plugin). I do not do a lot of coding, so bear with me. It seems so simple I have a link: http://www.domain.com/?code=8765 ...
2
votes
0answers
127 views

Setting HTML properties in a Gutenberg plugin using WordPress settings

I want to set the maxlength property on a TextControl I define in a Gutenberg plugin. This length is to be set from a setting in my WordPress plugin (the one that loads the Gutenberg plugin). I ...
1
vote
0answers
318 views

Woocommerce Create custom product type with variations

I have a plugin of booking that create a new product type of WC_Product. I'll like to change this booking product type for variable booking product type (new product type of WC_Product_Variation or ...
1
vote
0answers
37 views

Show only one variaton in catalog on meta key

Hello i have too much products with variations. I need display only one variations if enable. Catalog display data via taxonomy.php and basic loop. How i can show only one variations but in filter i ...
1
vote
0answers
29 views

Add comments for template variables

I am writing a small plugin that uses a custom template to render content. The plugin uses extract() to add variables that can be used inside the template. I was wondering if there is a standard for ...
1
vote
0answers
436 views

Get custom post type's fields in a while loop as variables

I'm working on a page that shows the name of a lot of products (custom post type), and when the user clicks on the name he can see some product information. It's something like this: Main page with ...
0
votes
0answers
28 views

Multiple values for one variable

I have a custom plugin that was written by someone, I can't reach anymore. It has a search option, that produces a table with seminars in different cities. Right now I can have a query with this ...
0
votes
0answers
21 views

Create new meta field with existing field data on publish

I am using a frontend publish plugin that uses Wordpress's default publishing hooks to publish, and I am trying to create a function that will grab the data of one of the fields in the frontend form, ...
0
votes
0answers
33 views

Force selected attribute variable of a product for all products in Woocommerce

If a custom chooses variable blue color of product, in all other products blue color variable should be forced (auto selected) If this possible how can I do it? Thank you
0
votes
0answers
18 views

How to get list of (all) predefined variables?

Is there a list of all the WordPress predefined variables? Like, for example, this php manual page. I could not find it in the new WordPress Code Reference, while in the "old" Codex the page seems to ...
0
votes
0answers
26 views

How to display variables from plugin?

I've been working on creating my first homebrew plugin for our site, and I'm so daggone proud of what I've been able to do so far. The plugin is called by a shortcode - in the plugin, I've ...
0
votes
0answers
166 views

fix undefined variable in native wp files

I had a trouble with installing new plugins as I would get error message "Something went wrong" when trying to search for any plugin. When I enabled wp_debug i got error saying Notice: Undefined ...
0
votes
0answers
413 views

set_price in woocommerce_before_calculate_totals not working

I am trying to update the price of the product based on user input on the product page. add_action( 'woocommerce_before_calculate_totals', 'extra_price_add_custom_price', 9999, 1 ); function ...
0
votes
0answers
18 views

Passing along User related Variables between two pages?

My situation and my problem: I have about 200 pages of a custom post type on my website. A user can click a button that reads "Add to my List" on each page which adds a custom taxonomy term to the ...
0
votes
0answers
21 views

Imported products - show price only when save again variantes

I imported product when BrandSync plugin. Some products do not have the visible price. But if you go inside the product, save the variants again, the price appears. How can I solve?
0
votes
0answers
83 views

WP CLI - Pass Query / URL Variable to Cron?

Is there a way to pass URL / Query variables when you run: wp cron event run using WP CLI? I have a specific event and ID I want to pass to it but don't know if it is possible or how to pass GET ($...
0
votes
0answers
160 views

Adding more than one variable in this function

I would add more than one variable into the following function (for example 'referral_code', 'variable_2', 'variable_3') but I can't do it. Can anyone help me, please? Cheers! add_action( '...
0
votes
0answers
71 views

Where can I find the declaration of `$_wp_theme_features`?

Where can I find the declaration of the global array $_wp_theme_features on WordPress core?
0
votes
0answers
33 views

Can't access a variable defined in another template despite using GLOBAL

I created, populated and successfully echoed a variable x in header.php. Then in my front page template I did global $x then echo $x. This displays nothing. Why?
0
votes
0answers
60 views

Custom Taxonomy Link Text Echo Name Not Slug

I'm a little lost about where I can place a simple php echo within a loop. I have a "program" taxonomy where each program is echoed onto buttons. Right now I'm only echoing the slugs for the link ...
0
votes
0answers
658 views

Setting a cookie in functions.php and it gets deleted when working on an other function

My first function gets the parameters from the URL and sets the cookies: /** Get variables from the URL and set them into the coockie **/ add_action( 'init', 'set_utm_cookie'); function ...
0
votes
0answers
64 views

Best way to access variables in template markup

I am making my own mini OOP wrapper for working with wordpress themes. I have a main $settings variable that contains all of the information like definitions, scripts, menus etc.. I then pass this ...
0
votes
0answers
286 views

Pass variable to next page

I'm putting simple breadcrumbs in a site, based on a custom post's category. Items > Category > Individual Post "Items" doesn't change, it's just plain text. In the Category page it's title is ...
0
votes
0answers
438 views

passing javascript variable into php wordpress

I am trying to pass variable from JS to PHP. I have this JS code that runs in my footer.php: <script> function printResponse(response) { if ( response.errorCode == 0 ) { var ...
0
votes
0answers
1k views

Passing variables through a href link from one page to another page

On my registration site I have a CPT called "event". In my "Events" page I list these events and create a "register" link for each one towards the "Registration" page: $events = new WP_Query( array( ...
0
votes
0answers
224 views

Create and update Custom Cookie based on multiple GET and POST Values for first time visitors?

I am not exactly sure the most efficient way to write this code. I collect custom data in my forms and also in my url via get such as: Name utm_campaign URL Referrer ID Among many more. Do I really ...
0
votes
0answers
86 views

Displaying posts by year

I'm trying to display posts on the homepage from the current year only. I am using the following: <?php if ( is_front_page()) { ?> <?php $current_year = date('Y'); ?> <?php ...
-1
votes
0answers
51 views

Im trying to supply the post ID to a plugin function in the plugin file. But instead of the value, its NULL

TY for opening my question! Im trying to update the meta key 'license' in a custom post that I have, with the ID of an existing WP post. So Im using a global variable to store the ID of the WP post ...
-1
votes
0answers
30 views

Custom Variables are not being passed

Custom variables that are in a custom global.php file are not being passed to a homepage.php, I have set up as the static homepage for WordPress. It just gives null errors as if the variable doesn't ...