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
1answer
96 views

Need some PHP schoolin'! passing var to url and the old options table

So, I've been building a theme options page, one of the purposes of which is to get some style values to pass to my php stylesheet in the url. Here's what I have: /* Get all theme settings */ ...
0
votes
3answers
631 views

If I define a variable in header.php, how do I make it available to templates?

I've defined a variable in my child theme header.php. I'd like to get the value of this variable from one of the templates that is rendered after the request in which the header.php is called. So, ...
0
votes
3answers
336 views

Get attachment if matches a variable

how do I match an image title from the media library to a variable then echo that image? this is my current code... <?php $args = array( 'post_type' => 'attachment', 'numberposts' =...
0
votes
2answers
767 views

Shortcode not passing variable to included file

I set up a shortcode which includes a standard php/html form file. In the form I have a hidden field where the value is a variable which is meant to be available in the form via the shortcode ...
0
votes
2answers
698 views

ACF allow zero as a value

I would like to have 0 to 5, and "n/a" as possible values, however this code will output "n/a" when I want it to output a zero. How can I get it to output "0"? ("n/a" is the placeholder if no value ...
-1
votes
2answers
2k views

Can't get options with $data['variable']

Can't get options with $data['variable']. (I'm use SMOF - Slightly Modded Options Framework) For example in the header.php (index.php, footer.php, etc.): global $data; $logo_type = stripslashes( $...
-1
votes
1answer
8k views

How do I access variables outside a function [closed]

I have a custom function which defines a bunch of variables. I would like to be able to call this function from inside a loop so I can have access to all its variables, like so: functions.php ...
-1
votes
1answer
49 views

Global Handle to Class unavailable in Plugin?

I am writing a custom plugin and calling the plugin functions using short codes on my wordpress page. global $db_handle; below declares the handle to the class 'DBController' global. if (isset($...
-1
votes
1answer
247 views

Need help, Passing variables with get_post_meta

$slider_image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'slider'); $slider_thumb = wp_get_attachment_image_src( get_post_thumbnail_id( $post->...
-1
votes
1answer
53 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 ...
-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('...
-1
votes
1answer
100 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/...
-1
votes
2answers
80 views

Wordpress loop put title into variable

I am trying to get the permalink and title into variables to use outside of a loop - I have made it work for the thumbnail but for some reason can t get it to work for these two. Here is my code: &...
-1
votes
2answers
44 views

Trying to get this function to show below the content

I'm looking to run a function 'catloop' after the content. Instead of just placing it below the_content(); I wanted to do it the right way. There is also a social plugin that places some sharing ...
-1
votes
1answer
779 views

Import and use a variable in additional settings of Contact Form 7 [closed]

I want contact form 7 to redirect to a specific page when on_sent_ok is successful. Unfortunately, the domain of the page to which I want to redirect is not fixed, it changes time to time. But, the ...
-1
votes
2answers
174 views

add variable to actions/functions across different files (woocommerce)

I'm using woocommerce which is working fine. On the template for the related products for example you'll find this: <?php woocommerce_product_loop_start(); ?> This calls the loop-start.php. ...
-1
votes
1answer
51 views

How do I echo saved data outside the function?

I know the data I want is stored as $lineOne and I can echo that inside the function. But I want to get the data outside of the function. I've tired: $lineOne; $instance['lineOne']; Here's the ...
-1
votes
1answer
205 views

Having problems accessing $_GET values

I'm trying to get the value of a $_GET variable on the homepage of my site. For some reason I can't access any $_GET variables on the homepage, but I can access them just fine on other pages. Does ...
-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 = '<...
-2
votes
1answer
2k views

Use ajax response in PHP function

Ok, so I'm working on a plugin and just ran into a problem. Here's what I'm doing: 1. Using a metabox with Plupload to upload an image to an upload dir in the plugin folder. 2. Upon upload success a ...
-2
votes
1answer
86 views

Using Form to alter PHP variable [closed]

I'm pulling custom posts by their meta_key using this function: <?php $args = array( 'numberposts' => 10, 'meta_key' => 'allvotes', 'orderby' => 'meta_value'...
-2
votes
1answer
80 views

How to store wordpress title in a variable

trying to run a PHP youtube v3 data in a WordPress theme $grab=ngegrab('https://www.googleapis.com/youtube/v3/search?key='.$devkey.'&part=snippet&order=relevance&maxResults=5&q='.$...
-2
votes
1answer
829 views

How to pass variable to functions.php?

I have a variable, created in page.php, and would like to pass this to a function in functions.php. Possible?
-2
votes
1answer
26 views

Add variable : 1 Week ago

Could you explain to me how add filter date : "1 week ago" Thanks for your help /* Variables from the widget settings. */ $title = apply_filters('widget_title', $instance['title'] ); ...