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
305 views

What's the best way to echo out a filter variable?

I have a plugin filter that isn't working for me: add_filter( 'gform_notification_email_3', 'route_notification', 10, 2 ); function route_notification($email_to, $entry) { global $post; $...
0
votes
1answer
142 views

Preventing Duplicating Posts from Widgets

I am making a theme that has the main loop in a widget. Also widgetized is a feature slider and a display of four feature post boxes, each with their own loop. How do I prevent duplicate posts from ...
0
votes
1answer
356 views

How to add a new variable to blog creation form?

I'm trying to add a new INPUT field to the blog creation form on Buddypress. Adding the front-end element is the easy part. I'm having some hard time trying to save it. The variable is a string, and ...
0
votes
1answer
146 views

Defining the value of a variable before a function?

I'm trying to edit a plugin so that it only shows it's submenu if the user is an administrator but I don't know how to define the value of the variable before the function: function load_view( $name, ...
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
28 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
49 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
31 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
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
101 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)); ...
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
243 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
601 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
46 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
212 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
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 $...
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
232 views

Add class to all meta boxes for a custom post type

I am using an OOP approach to doing all the work in creating the CPT and its meta boxes. For admin styling purposes, I want to do some heavier styling for a specific custom post type. My object method ...
0
votes
1answer
312 views

I need some explanation on global $post [duplicate]

Sorry if this sounds like a dumb question but it's something that has bugged me for a while. I need some explanation on function custom_function () { global $post; } I understand from PHP that ...
0
votes
1answer
41 views

Get specific value from variable to use in query

I would like to create a custom query where the post ID is equal to a value which is stored in a variable. If I do a var_dump of the variable I can see the ID that I want to use. However I don't ...
0
votes
1answer
77 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
21 views

Using a variable in name of dynamically-called helper function

I'm trying to add some functionality to my "Settings" page so that if a new season is added in a custom post's metabox, a new field is generated in Settings to allow users to add a title and ...
0
votes
1answer
666 views

WooCommerce 3 get custom variation on process order [closed]

I will try to be precise. What I want to do is next. I want to add a custom field in variable products in variations and then to use it when I order is in process(in gateway settings). That field can ...
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
48 views

Add a variable in a post

I would like to control a number inside multiple wordpress posts only by changing a variable. This variable can be anywhere inside wordpress or any document accessed by ftp.
0
votes
1answer
300 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
88 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
84 views

Passing variable from template file to the plugin file

I need to send some variable from template file (themes/template/page-profile.php) to the plugin file(plugin/instagram-slider/instagram.php). For example: I have $instagram_url = get_user_meta($...
0
votes
1answer
731 views

Undefined variable & issue with smof_data

i'm helping my collegue with his current page and I've stucked with an error: Undefined variable: alignment It reffers to the following piece of code: if( ! function_exists( 'avada_page_title_bar'...
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
550 views

Pulling a variable into the wp_nav_menu function

I looked around and couldn't get any answer that helped me. I have an include that I am calling in multiple headers (I have different headers for different sections of a membership site that need ...
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
118 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?