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.

0
votes
0answers
9 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
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
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
390 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 ...
1
vote
1answer
424 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'...
0
votes
1answer
541 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
425 views

Replacing string with a variable in php

I have following code in my plugin of Wordpress: wp_localize_script('ffd_js_script', 'myAjax', array( 'ajaxurl' => admin_url('admin-ajax.php'), 'idinfo' => $...
0
votes
1answer
13 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
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
62 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
538 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
1answer
57 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
3answers
528 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
11 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
506 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
504 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
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
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 ...
6
votes
5answers
7k views

Where to get information about array fields in $_REQUEST?

I just started to learn PHP and doing things with WordPress and I am a bit confused about information in Codex. Was told that Codex got all info I required but I got stuck with it. What array fields ...
0
votes
1answer
21 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 (%...
51
votes
9answers
58k views

Passing a variable to get_template_part

The WP Codex says to do this: // You wish to make $my_var available to the template part at `content-part.php` set_query_var( 'my_var', $my_var ); get_template_part( 'content', 'part' ); But how do ...
-1
votes
1answer
26 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
0answers
46 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
27 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
140 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
35 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 ...
1
vote
2answers
882 views

How to get variables from fucntion.php to my plugin files

I have written a function in functions.php that gets variables from a contact form and sends the inputs (and some other info like IP and location..) to my email. I am starting to work on my first ...
0
votes
1answer
194 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
0answers
476 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 ...
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 ...
0
votes
1answer
97 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
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
1answer
2k views

Rewrite Rules problem when rule includes homepage slug

I have page Example (ID=443, slug=example) that is configured, through Dashboard->Settings->Reading, as the home page of my WP site. I also have the following rewrite rule configured: [(example)...
0
votes
3answers
21k views

Use conditional logic for woocommerce variable product

I have been developing a woocommerce store. Now I have a requirement from client which I can't figure out how to do... The problem is we can use variable product in woocommerce, it's simple but what ...
0
votes
1answer
160 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
30 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
1answer
30 views

Add audio file to post using custom term meta field as link [closed]

I am trying to add an audio file to my custom post type using a custom term meta field as a link, but I can't get it right. Here is how I would normally display a custom term meta field: <?php $...
5
votes
1answer
7k views

How to Use Wildcards in $wpdb Queries Using $wpdb->get_results & $wpdb->prepare?

I am attempting to make a custom search for BuddyPress groups. Here is my method: public function search_groups($string){ global $wpdb; $results = $wpdb->get_results($wpdb->prepare( ...
0
votes
0answers
204 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
344 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
36 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
votes
1answer
19 views

PHP Use Declared array Variable inside already Declared Array

i have created one class in which i declared public associative array. class test{ public $basicCols= array( array('title'=>'KEY', 'field'=>'slug','options'=>$optList), array('...
0
votes
0answers
19 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
2answers
113 views

javascript variable to wordpress php variable

I need to push js variable into php variable. AJAX url is set via wp_localize_script but it returns ERROR 400 Bad Request. functions.php is looks like wp_localize_script( 'script-js', '...
2
votes
2answers
762 views

Undefined variable post_id in custom quick edit coloumn

I am trying to add a custom coloumn to post quick edit and everything is almost working. Custom meta is saved and passed but if I click on quick edit the preview is blank. This is the error it gives ...
1
vote
2answers
1k views

Variable in Array Not Working

I having an issue getting a variable to work for one of my arguments in a query. I am using a custom post type and category name as terms to determine which categories are displayed. When I hardcode ...
1
vote
0answers
39 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
votes
1answer
92 views

Product atributes in title of order (not in description)

I have couple of variable products. When someone order product, some product displey in new variation format (where order atributes are in title). Image: https://user-images.githubusercontent.com/...
0
votes
1answer
146 views

Substite Category Slug in a Shortcode

I'm struggling with substituting a variable for a hard-coded value in a shortcode. I'm using the following shortcode (written by Ahmed Fouad --thanks Ahmed) at this link which counts the # of posts ...