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.

72 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
4
votes
0answers
804 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
152 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
364 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
41 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
1answer
463 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
0answers
30 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
2answers
530 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 ...
1
vote
1answer
557 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['...
1
vote
0answers
440 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
11 views

Theme customisation - how to store common variables externally

I have been developing a custom extension for my theme over the last few weeks. This is my first time "developing" with Wordpress. All works fine and I am happy with the resulting functionality, ...
0
votes
1answer
31 views

Theme customisation - how to store javascript externally when it utilises php variables?

EDIT: Complete re-write I have been developing a custom extension for my theme over the last few weeks. This is my first time "developing" with Wordpress. All works fine and I am happy with the ...
0
votes
0answers
6 views

Variation availability by date

I'm working on a website that wants to sell four different courses. These courses are each available four or five times every year (so Course 1 might have a session in February, April, June, September ...
0
votes
1answer
46 views

How to change the value of a variable using input field?

I have created a wordpress website. I want to extract each user's data using php through his/her id. I have created this code; <?php $userid = /* help me get the below input field's value */ $...
0
votes
0answers
50 views

Send Front End PM Message after Succesful Ultimate Member Registration

We're working on a Wordpress project which requires: - a list of Therapists with a "Contact" button for each (done, listed with Store Locator and an Ultimate Member user group for the Therapists) - ...
0
votes
0answers
24 views

Pass Underscore.js Variable to a Shortcode

I am using WP Store Locator to list nearby "Therapists" (therapists=custom user group with Ultimate Member, this part of the project works perfectly) and Front End Pm for a basic messaging ...
0
votes
1answer
25 views

Defining constant in a plugin to use in another plugin

I am wondering if this is possible or if there is another, better way, of doing things. Google-foo didn't help. So, I have two plugins, aa-frontend and aa-site. I need to define a constant or ...
0
votes
0answers
10 views

Passing a variable in a customer url menu

I'm trying to add a link to my menu that leads to the following page: /ar/variable where the variable is the page the user is currently visiting for example: when the user is on page site.com/contact ...
0
votes
1answer
20 views

Pass post ID from archive template to functions file

I have an archive template where I am displaying a "featured post" at the top of the page. I am building my post loop for the rest of the page in the functions.php file. What I would like to do is get ...
0
votes
0answers
40 views

How to access custom class methods from any include without using global

I am trying to do the following functions.php class Test { public function hello(){ return 'Hello'; } } $test = new Test(); header.php or any other include echo $test->hello();...
0
votes
1answer
12 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
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
22 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
53 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
1answer
609 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
0answers
19 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
48 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
213 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
523 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
1answer
2k 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
78 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
370 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
301 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
0answers
89 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
1answer
270 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
398 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
34 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
119 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
0answers
79 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
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
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
3answers
534 views

Passing variable from child theme function to parent theme filter

I want to pass a variable from my child theme function to a filter which resides in my parent theme. Please let me know whether below code will work or not ? Is it the right way ? Code in Parent ...
0
votes
1answer
38 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
0answers
63 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
674 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
1answer
136 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
0answers
294 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
1answer
43 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() { ...