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.

Filter by
Sorted by
Tagged with
0
votes
0answers
5 views

I need a variable for generating woocomerce coupon at checkout

I need a variable set-up for my customers to apply at checkout that will generate a unique different coupon code for different customer, and the coupon generated should expire in 48 hours after ...
0
votes
0answers
18 views

how to create a shortcode from a variable in plugin

im using WP User Frontend Pro plugin i want to echo the pack title using a shortcode to put it in bakery visual all what i know is this is the title $pack->post_title; i tried something like this ...
1
vote
1answer
68 views

How to rewrite URL with PHP variables with htaccess to a normal looking URL?

I want to change an old database website that is not made in WordPress to WordPress. My site uses PHP variables so the URL is originally: example.com/index.php?tl=1&pg=2&bs=3&hcbs=4&...
0
votes
0answers
49 views

Reduce Stock Based on Custom Variation Field Rather than Attribute (Working Script)

I currently have a script that works perfectly. The issue is, I want to use the value in a custom field I have created for my variations rather than an attribute. See code: // reduce stock based on '...
1
vote
0answers
13 views

Remove add to cart icon/view product button woocommerce

I'm trying to remove a button that appears when hovering over the images on a woocommerce shop. (See images attached) The product is a variable product. Failing being able to do this I also tried to ...
0
votes
1answer
20 views

where is real values of variables?

I am working on editing the theme now for our center website, we are using Benevolence WordPress Theme. My question might look too obvious to most of you but I am new to word press and spending too ...
0
votes
2answers
53 views

Use one javascript variable into another javascript file

This is common.js jQuery(function ($) { var commonJs = { init: function () { }, showAlert: function () { }, } }); This is add.js jQuery(function ($) { ...
0
votes
0answers
17 views

Using a function / displaying the result of the function twice in same page

I have a script showing open/closing times. It is displaying fine when calling the function in my header file. When I try to call it in my mobile menu - CRASH - nothing or errors etc. (depending on ...
0
votes
2answers
40 views

Insert page content into another page with a changed variable

I'm trying to use this simple code to insert page (1) content into another page (2): <?php $id = 216; $p = get_page($id); echo apply_filters('the_content', $p->post_content); ?> So far so ...
0
votes
1answer
14 views

Local variable name in setup_postdata()

I am new in wordpress, I was using setup_postdata() method inside of a template file which was being called via shortcode function. I have not used global $post in my function. if ( ! function_exists(...
1
vote
1answer
73 views

Getting RGBA colour from gutenberg colourpicker

I'm working on a block that has it's own colour picker. This is working fine and I can see my background colour changing however I'm only able to get the hex value for the colour. I'm changing the ...
0
votes
0answers
13 views

What is better for passing variables to templates - include(locate_template.. or $wp_query->query_vars?

The answers here: Passing variables through locate_template are extremely helpful in solving the problem of passing variables to templates such as sidebar and footer. In short, which is best? ...
0
votes
1answer
18 views

Pass Variables or Variable Place-Holder from Editor to PHP

I'm building a method for my client to construct a message content to be sent with wp_mail. Within that I'd like them to be able to choose variables, for example the message might look like this in my ...
0
votes
0answers
31 views

Woocommerce; tax status for product variations?

I noticed that when creating a new variable product in Woocommerce and setting the tax status of the parent product to 'none', the variations still show: 'tax status: taxable' in the database. Does ...
4
votes
2answers
2k views

Pass a PHP variable to another file

Is there a simple method to passing data from one file to another? I'm new to PHP and can't find a simple answer to my problem online. Apologies if this has been answered a million times & thanks ...
0
votes
0answers
24 views

Get attributes for currently product

I have code: <?php $attributes = $product->get_variation_attributes($variation_ids); $attribute_keys = array_keys( $attributes ); ?> <?php foreach ( $attributes as $attribute_name => $...
0
votes
1answer
254 views

How do I fix Undefined variable using $_POST in function?

I have the following function but with this error: Notice: Undefined variable: rating. hoa can I fix it? function save_comment_meta_rating($comment_id){ if(!empty($_POST['rating'])) $...
0
votes
1answer
114 views

Undefined variable error in new function

I wanted make function to count the time last the user read the article but after putting it in fuctions.php I see this error: Notice: Undefined variable: post in /home/karnetac/public_html/wp-...
0
votes
1answer
25 views

How to access or parse key/values that have “string”

Coming from a Perl background (no snickering) and trying to make sense of some new conventions. Not sure whether this is a PHP, WordPress, or Ninja forms question. $form_data //Ninja parlance ...
0
votes
1answer
66 views

Getting value of variable from functions.php and debugging it

I am trying to inspect a variable obtained in functions.php for debugging purposes. I am defining a variable $current_user by executing the shortcode to obtain the current logged-in user. Then I am ...
0
votes
0answers
14 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
41 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
265 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 ...
-1
votes
1answer
193 views

Use a Variable in update_post_meta as the $meta_key

looking at the example on wordpress.org update_post_meta( $post_id, $meta_key, $meta_value, $prev_value ); I seem to be having a problem replacing $meta_key with a variable. here is my code ...
0
votes
1answer
354 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
286 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
39 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
116 views

Passing function into add_action always returns the first argument

I'm building a plugin that iterates across and parses the arguments of various WordPress hooks, and because of the flexibility needed I'm passing a function as the callable parameter in add_action: ...
0
votes
1answer
119 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
14 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
30 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
42 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
184 views

Turning variable into a value set in shortcode

I have a site on WordPress, and first of all I have this PHP shortcode that helps me to make customizable links in WP post editor without turning my CSS files into a dump of classes with basically the ...
0
votes
1answer
1k views

How to unset a set query variable?

My theme file, multiple times over, passes sets a variable to a template part used in a subsequent template part file via set_query_var, like so... set_query_var('feature_id', array(143866)); ...
1
vote
1answer
274 views

Using a variable in is_page(array())

Similarly to this topic I need to extract some page IDs from user input (a theme options admin page), store them in a variable, and then filter using the is_page() filter. The input consists of ...
0
votes
1answer
50 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
34 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
1answer
22 views

Post URL based on Custom Post Types variables

I would like to create custom post URL from Custom Post Types variable. I considered a way to do that: In Permalinks settings, I see there are some default tags you can choose to compound URL from (%...
-1
votes
1answer
28 views

How to filter part of a variable if it is no array?

I was wondering if it is possible to filter out a part of a variable, if it is no array. Or can I only replace the whole code, or add code to it? Let's say I have this code: $output = '<...
0
votes
2answers
65 views

html element to separate php variable strings - ACF datepicker

i am using ACF to display an internationalized date with this code : <?php $dateformatstring = "l j F Y"; $unixtimestamp = strtotime(get_field('date')); ?> <?php echo date_i18n($...
2
votes
0answers
284 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
1answer
73 views

Plugin. Html code in Template

perhaps i am blind or something but i searched alot, here and also wordpress codex and similar. In example i wrote a plugin that reads something from database and print someting. But how can i archive ...
0
votes
1answer
967 views

How to find php variable of wordpress theme settings

I'm new to PHP and WordPress, but I have some experience with python, for my site I use the traveller theme. How can I find the exchange rate variable that exists in theme settings (the red square on ...
0
votes
1answer
1k 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
289 views

How Do I Find & Remove H1 From Site-Title-Wrapper? [closed]

Good Afternoon, I am having difficulty removing a duplicate H1 tag, which is located in my Site-Title-Wrapper, per source code. When I access "Edit Theme" and load the "site-title.php" I can see the ...
0
votes
1answer
464 views

Changing the order of custom fields in the dashboard for Woocommerce variable products [closed]

I followed this quick/well laid out wordpress tutorial for adding custom fields to WooCommerce variations. http://www.remicorson.com/woocommerce-custom-fields-for-variations/ Everything worked great....
0
votes
0answers
244 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
344 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 ...
1
vote
0answers
502 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 ...
0
votes
1answer
40 views

Trying to Create a PHP Variable for post_type that can be referenced Site Wide

I have several sites with several custom PHP widget loops I've created. I would like to reuse these widgets in other areas and site, but with different custom post types. The only unique thing in ...

1
2 3 4 5
7