Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

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
1 vote
0 answers
22 views

Changing static text in a theme into variable content that also respects language. Easiest way

I bought a Theme which unfortunately has some static content, I managed to hide and remove some via editing and the custom css. But I have a text field above the navigation where it says "Work ...
user avatar
  • 11
0 votes
0 answers
6 views

I have a wordpress woocommerce website, in this website i want short description changes automatically based on the selected variation like amazon? [closed]

Dear All, i have a wordpress woocommerce website, in this site there are products, some are variable and some are simple, i want to change woocommerce short description to change automatically based ...
user avatar
0 votes
0 answers
8 views

WooCommerce Subscriptions: Hide one variation subscription

Woocommerce subscriptions | All Products for WooCommerce Subscriptions Does anyone know if there's a way to disable the subscribe option for a specific product variation? i.e. product with 2x ...
user avatar
0 votes
1 answer
17 views

Get access to variable from previous pageview, excluding ajax-calls

I want to generate a random string, and get it passed to the next pageview. I currently have the following code: add_action('init', 'set_global_pixelcapival'); function set_global_pixelcapival() { ...
user avatar
1 vote
0 answers
33 views

Result of API Request to global variable?

I have an API Request for weather and the account of this weather stuff has a limitation of requests per minute. In my theme I have the weather information twice on the same page. So if I would make a ...
user avatar
  • 11
0 votes
0 answers
28 views

Pass global variable from Page 1 to page 2 (Pagination)

Ultimately to keep it real simple, on a custom query page, I have a global variable that I pull from a previous page. When I go to page 2… the global variable is blank. Page 1: Define global variable....
user avatar
  • 125
0 votes
0 answers
28 views

Form Post / Session Variables not Working in Query with Pagination

I am developing a custom search where the user inputs data on the first page with a form. Upon clicking submit, the user is brought to a second page for the results. I pass the data via pulling in the ...
user avatar
  • 125
0 votes
0 answers
19 views

Updating custom query var with multiple values

I'm using set_query_var to bookmark snippets that were already published, in order to exclude them from other independent loops on the page. Basically, so that no title ever comes up twice. Basically ...
user avatar
  • 312
0 votes
1 answer
104 views

How to display emails as a post?

I am creating a Plugin that displays e-mails as posts. I used the following PHP to access those emails: <?php class Email_reader { // imap server connection public $conn; // inbox ...
user avatar
0 votes
1 answer
197 views

How to send a php var to jQuery Ajax call with two different file

I need to send a private e-mail address from a php file (page.php) to an Ajax Call in an other jquery file (sender.js). This e-mail address must be invisible to user/or website until the user get an ...
user avatar
0 votes
0 answers
32 views

edit user input data contact form 7

I have created a form that posts user input to an API, in my function I have multiple Posted Data entries that take the value from my user input. In my $body variable I have set it to receive the API ...
user avatar
  • 11
0 votes
0 answers
25 views

Unable to display multiple parameters from url by javascript through shortcodes

From our CRM I can generate URL's for customers that includes parameters. I want to use the information stored in this parameters to show dynamic content to the customers. Example: www.example.com/...
user avatar
5 votes
1 answer
272 views

Is there a way to extend WP_query so Custom Post Types can have properties?

Having trouble finding info on this. When working with lots of metadata/custom fields, I would really prefer to simplify getting the meta data inside of templates instead of using get_post_meta and ...
user avatar
1 vote
1 answer
44 views

Variable global scope [closed]

I'm trying to create a few custom post types, and instead of hard-coding their names I just want to define them as a globally scoped variable. I thought I understood the scope but apparently not. The ...
user avatar
  • 21
0 votes
0 answers
185 views

How to check a variable Changes

I have a variable $curr_price. Every time some user updates the variable, I want to show a message to the other users. Should I use a jQuery script something like this: $("curr_price")....
user avatar
1 vote
0 answers
55 views

Is there a way to show Single Variation prices in the product loop when filters or attributes are active?

I have a WooCommerce store with variable products. Some products have 3 different attributes that are used for variations ie; Size, Comfort Level and Turning Cycle (as an example). I would like to ...
user avatar
0 votes
2 answers
55 views

Change Page Title

I have successfully changed the name of a specific page using this code in my functions.php file: add_filter('pre_get_document_title', 'change_my_property_title'); function change_my_property_title($...
user avatar
0 votes
0 answers
20 views

Get the variable from wordpress widget into functions.php

I would like to ask for help regarding my task. I have a widget card in a WordPress entitled for instance widget-post, then, inside that widget, I have declared a variable for eg. $variable_name = '...
user avatar
0 votes
1 answer
21 views

How to deal with too many $_POST variable conditions from ajax request at backend? [closed]

At work, we write a PHP application. I'm only a junior, but I'm dissatisfied with the problem of processing AJAX calls. Each of AJAX request is directed to the single appdata.php script. At appdata....
user avatar
1 vote
0 answers
41 views

Pass variable from one function to another

I am trying to pass a URL and query string from one function to the other, as in the other function it captures the incorrect string, each time I try and pass it through to the second function it ...
user avatar
  • 11
1 vote
2 answers
192 views

Get value from shortcode to do something

For a project I want to use advanced shortcodes. Normally I define shortcodes within my PHP. This way it is always the information I have in my PHP-files that I show with my shortcodes (like [...
user avatar
0 votes
0 answers
15 views

how to create variable like this %user_posts_page% or like this {user_posts_page}

I am tryiing to create variable like this %author_posts_page% or like this {author_posts_page} to use with Wp user avatar plugig to generate profile link for user avatras. But this not work for me. $...
user avatar
1 vote
0 answers
50 views

Set and access global variable

I am learning plugin dev and modified this example snippet. I don't get why $myvar is empty in the my_plugin_action_handler function's scope. <?php /** * Plugin Name: TEST Plugin */ global $...
user avatar
0 votes
1 answer
13 views

Custom column on CPT not showing correct value when meta data not set

Basically I have 2 custom columns in the 'edit.php' of my custom post type. What I need is when $item_type is set to 'page' but there is no page selected, 'No selection' is echoed (same for when '...
user avatar
0 votes
1 answer
374 views

global $product is empty string when passed into function

I'm trying to optimize my functions.php file as I have a Woocommerce site with a bunch of customizations to the theme. Currently, my functions look like the following: add_action('wp_footer', '...
user avatar
0 votes
1 answer
122 views

Check if parent page has child page of certain slug

I currently have a function that checks to see if the page is a parent, and if so, do stuff. But I also want to check to see if the parent has a child page that has a certain slug. Basically, how ...
user avatar
  • 134
0 votes
1 answer
126 views

Can't pass var from php wp_ajax into ajax script : result undefined or null

I can't understand why I get always a null or undefined response while trying to pass an php error from registration form into ajax script. I work in a custom plugin to add login, registration and ...
user avatar
0 votes
1 answer
98 views

RTrouble passing arguments to action

I know there are several posts on this topic. I have followed many of them as well as other resources on the web and thought I had it down, but it does not seem to be working. In my case, I have 2 ...
user avatar
  • 191
0 votes
1 answer
72 views

Variable inside shortcode or shortcode inside shortcode

I have a working shortcode, ie like this: [shortcode_name search="" show="url, color, size"] In this shortcode if I insert for example an email inside search (search="test@...
user avatar
  • 11
1 vote
0 answers
131 views

Shortcodes — Using add_action, add_filter in the shortcode

A client wants the following: User clicks on a specific button which takes them to a partner's site. If this is their first time clicking the link, they need to accept terms and conditions. If they'...
user avatar
  • 31
0 votes
2 answers
1k views

What is the alternative code to if (isset ($_POST) && !empty ($_POST) to avoid warnings?

I am trying to insert some php code to my WordPress website but it gives security warnings perhaps due to directly accessing $_POST variable. Instead of $name = $_POST['name'];, I can use $name = ...
user avatar
  • 115
0 votes
1 answer
67 views

Custom global variable not working in function

I've been stumped on this for a while and cannot for the life of me figure out why my function isn't able to reference my global variable. $query_obj = get_queried_object(); if ( is_a($query_obj, '...
user avatar
0 votes
1 answer
32 views

Add text to variable

i am adding a option to a plugin. I want to add a Subfix after the curent test variable is return from a summarizer. So my data is in excerpt variable and i want to add text that is in this variable $...
user avatar
0 votes
1 answer
337 views

WordPress How do I pass a variable from one add_action to another?

I'm trying to add a custom field on the checkout form if a certain product category is in the basket and then on submission, check that field has been completed and add the result to the order details....
user avatar
0 votes
1 answer
945 views

keep a variable for all pages in memory from the url

I downloaded a referrer plugin and it works fine I create my custom link and everything is fine: https://testsite.com/?r=ty5x I have a conversion system that tells me how many users have come to my ...
user avatar
0 votes
1 answer
17 views

Function that replaces the image in the absence of the post meta

i have thtis function in functions.php file function post_manage_columns($column_name, $id) { global $post; switch ($column_name) { case 'Average': echo get_post_meta( $...
user avatar
2 votes
1 answer
22 views

Adding variable for post title so post template can include auto-generated link to view on external website.com/{post title}

There's an external website that I'll be referencing within my posts that uses the same static format for their pages. Let's say it's website.com/view/1111, website.com/view/1112, etc. What I want to ...
user avatar
0 votes
1 answer
28 views

get variables data from functions.php to template wordpress (without global variables)

I have in wordpress functions.php file This sample works with one variable only, but i want multiple variables function variables() { $var1 = 'lorem'; return $var1; } in the front template ...
user avatar
  • 3
0 votes
0 answers
79 views

Best way to use variables in multiple functions?

So I am running into issues in Query Monitor - duplicate queries. The reason being that I have functions that need to get say, a customer's order status or the like. What is the cleanest, correct way ...
user avatar
0 votes
1 answer
190 views

Trying to add some custom text into Wordpress Post title via function.php

I need to add a custom text in wordpress Post title dynamically which I'm trying to add via this code in function.php Following code is not working add_filter('the_title', 'new_title', 10, 2); ...
user avatar
0 votes
1 answer
24 views

Echoing a variable comes out with lots of white space

I'm having trouble when I get variables from WP function come out very long. How do I trim that down? trim and substr do not see the spaces before or after. Why is it so long? <?php $...
user avatar
  • 1
0 votes
1 answer
103 views

How to pass a variable to get_template_part that's updated every time the template part is called?

I have a loop and in that loop I use a get_template_part to call the HTMl for the post to display. I also have a variable (number) to which +1 is added every time the loop runs. In this way I can ...
user avatar
2 votes
1 answer
99 views

Cleanest/Fastest way to avoid calling and retrieving data from the database multiple times?

So this may be a very noob question, but I believe if I can get the answer to this I can clean up code and speed things up significantly. I build projects using Woocommerce quite a lot, and in doing ...
user avatar
0 votes
1 answer
41 views

What is the use of $content_width?

In the requirements of Envato I saw that they require a $content_width to be set. I searched for it on the internet but can't really understand why? I don't use it and the theme is responsive. If ...
user avatar
0 votes
0 answers
23 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 ...
user avatar
  • 1
1 vote
1 answer
2k 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&...
user avatar
  • 11
0 votes
0 answers
62 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 '...
user avatar
1 vote
0 answers
82 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 ...
user avatar
  • 11
0 votes
1 answer
54 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 ...
user avatar
  • 1
0 votes
2 answers
146 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 ($) { ...
user avatar

1
2 3 4 5
8