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
1answer
604 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
0answers
446 views

Get custom post type's fields in a while loop as variables

I'm working on a page that shows the name of a lot of products (custom post type), and when the user clicks on the name he can see some product information. It's something like this: Main page with ...
1
vote
2answers
76 views

Declaring <?php ?> in variables [closed]

I need to put the PHP <?php global $' . $icon_var . '; echo $' . $icon_var . '; ?> inside the variable of a custom menu structure, but it gets commented: <a href="http://slembas.esy.es/">...
1
vote
0answers
26 views

How to return Javascript variable to wordpress [duplicate]

I use this Javascript code to create a dialog box to ask some thing to user and after decide what to do depending of the response. function dialogToCont() { var retVal = confirm("Do you want to ...
1
vote
1answer
634 views

Escaping date string in url with wordpress

I am creating a Wordpress page that searches through posts based on a date variable that is set through a _GET variable. I want to make sure that I am doing this in the best way possible and that I ...
1
vote
0answers
230 views

Track usernames with piwik [closed]

I'm wondering if there is a way to send current logged username to Piwik and display it beside the ip address in the stats. I need to see which users viewed a specific page and which users downloaded ...
1
vote
2answers
2k views

Dynamic variable for custom taxonomy in loop?

I have a custom page template that loops through all custom posts with the post_type of "product_listing" AND the custom taxonomy "product_cat" of "shirts" and returns 4 posts per page (as seen below:)...
0
votes
2answers
2k views

What is the $current_screen global variable?

What does it mean by a screen? I've had a look in the codex and don't understand (I'm a newbie). Thanks.
0
votes
1answer
767 views

Populate Javascript code with value from Wordpress Custom Field?

I have a large amount of city pages on my blog where I need to put city-specific maps with additional control to build a route, on each city page. This is the layout I'm looking to create: I am ...
0
votes
1answer
145 views

Best way to pass variables around a WordPress site?

I'm building a membership site with a membership plugin right now. The different types of memberships are associated with IDs and I have to constantly do things like "show this if the ID is 4122 (i.e. ...
0
votes
2answers
84 views

How do I share variables between two functions?

So...here is part of my code for a plugin. I'm a newb of sorts so be kind. I've read up on global variables but I can't seem to get it to work and I've read you shouldn't use them anyway. So what ...
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
7k views

How to pass variables from a function in functions.php to an other one

I have a function that gets the variables from the URL (UTM): /** Get Parameters From UTM **/ add_action('template_redirect', 'get_the_utm_vars'); // 'template_redirect' - action hook that ...
0
votes
2answers
782 views

WPDB SQL query with prepare() returning variable, not db value

I have been trying to get this to work for awhile now and I cannot seem to get any farther on my own. It seems to work fine as a normal SQL query but not within the WP framework using prepare(). ...
0
votes
1answer
45 views

Variable not staying set

This is most likely just a PHP problem, and it's probably a pretty simple answer, but I just can't seem to get my brain to function this morning. This is what I'm trying to do: $job_file = $cfs->...
0
votes
2answers
4k views

Passing parameters to a static front page

I have googled a lot, but so far haven't come close to a proper solution yet. I need help with passing parameters to the homepage of a WordPress website. Here's my setup / requirements: I use a page ...
0
votes
2answers
3k views

Passing variables to new page

I'm trying to pass the variables to a new page, I made a function in my theme to get the results. Now when I use yelplist(); on the front page of my theme it gets the results and when i click on the ...
0
votes
1answer
49 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($...
0
votes
1answer
38 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 ...
0
votes
1answer
3k views

How to search variable product by its variation id in woocommerce admin product search box?

I need to search products somehow with ID in admin product search box and if it is a variations Id, then parent product will be listed. So that it can be identified, of which product it belongs too. ...
0
votes
3answers
146 views

Wordpress function and string as variable?

I am creating something which passes featured image URLs to a separate JavaScript file which uses parallax.js to create a parallax background for each entry for an archive page. This works fine when ...
0
votes
2answers
366 views

Assign custom parameter to each post in query

I'm trying to add an incremental variable to each post that comes up in a series of queries. The purpose is to calculate a weight for each result in order to be able to order everything later. This ...
0
votes
2answers
461 views

Passing stored variables to add_filter

I am working on a site where the page titles are generated dynamically from external data sources. So obviously, Yoast SEO/WordPress SEO doesn´t know anything about the correct title, description, ...
0
votes
1answer
61 views

Create a Wordpress shortcode using PHP [duplicate]

I am currently using the following code within single.php (after the_content) This gets the store_name from custom field as $merchant from the post and then returns a list of products from that ...
0
votes
1answer
85 views

Define PHP variable from a seperate API if statement

I am trying to put together a function that will echo certain text based on a range of numbers. One of number(s) I am trying to compare against is echoed in my template as such -- <?php if ( ...
0
votes
2answers
253 views

Global Variable vs Local Variable

// MOVE REVISIONS METABOX TO BOTTOM OF EDIT-FORM.PHP $post_types = get_post_types(); add_action('do_meta_boxes', 'batteryboys_reorder_meta_boxes'); function batteryboys_reorder_meta_boxes(){ ...
0
votes
1answer
818 views

Cleaner way to define multiple variables for is_page_template()

I need to so some stuff only when specific templates (homepages) are used, I couldn't think of any better solution than this since is_page_template() do not handle arrays: $home_1 = ...
0
votes
1answer
3k views

How to append a query string to pagination?

I would like to append 2 variables from page 2 onwards in my loop. This is my normal category page www.example.com/category/news/ This is what I would like on pages: 2, 3, 4, 5 etc www.example.com/...
0
votes
1answer
103 views

Custom Post not working as expected

NEW EDIT I solved it, as written in answer, the problem where that variables are 'forgotten' (not so techy I know, sorry for this) when function starts. EDIT: I found the problem is this: 'name' =&...
0
votes
2answers
2k views

IF Custom field value equals ZERO

I am trying to use the following code to check for my custom field for a value of ZERO to then display my div <?php $mp_price_sort = get_post_meta('mp_product_price'); if ($mp_price_sort == '0') ...
0
votes
2answers
1k views

How to put a form with php code into a variable or shortcode?

I'm trying to put my frontend form into a variable or a shortcode so I can wrap another shortcode around it (specifically Bainternet Post Creation Limits). My form has PHP code in it so I'm not ...
0
votes
1answer
2k views

Shortcodes and a list of IDs?

I'm creating a simple shortcode function and need to specify a list of IDs as a variable. I've checked the Codex but I'm not sure how this is handled. The shortcode is: [video_vote users="13027,...
0
votes
1answer
78 views

Trying to get variables in hacked category dropdown

I've discovered a workaround to get wp_category_dropdown to display as a multiple select field. My code is as follows: <?php $sponsors = wp_dropdown_categories( array( 'child_of' => 0, '...
0
votes
2answers
401 views

Child Theme Variables

In my theme, I used this: <div id="brickwall" data-brickinvert="<?php echo brickAlign(); ?>"> I put the code into functions.php: function brickAlign() { $a = "true"; return $a; }...
0
votes
3answers
3k views

Adding numbers inside a span tag in nav menu [closed]

I am working on a wordpress navigation menu and trying to simlpy (of course, dynamically) add number inside a span tag for each menu li item. So I created a "top menu" using the wordpress custom ...
0
votes
1answer
2k views

Apply class to every third list item? [duplicate]

Possible Duplicate: How to mark every 3rd post I'm trying to give a class to every third list item on my page. I know how to give a class to every item, but not to specific items in a row, or in ...
0
votes
1answer
2k views

Passing a variable from a FOREACH loop in a link

How would you pass a variable from a foreach loop, through a link? I have tabs that display correctly. The jQuery works. But when I call the variable $category down where the content sorts, $category ...
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
1answer
114 views

How to get CGI variables?

I need to do two things: Add a CGI variable (say filter=21) to the current query and make a link to this modified URL. Fetch the value of CGI variable "filter". How to do that in WordPress?
0
votes
2answers
359 views

persist a variable set in header.php all the way down to footer.php

I look up a custom post field value in header.php, and store it in a global variable. In most of my template files, the includes go like this: include header ...do a bunch of stuff include ...
0
votes
1answer
1k views

What does the Global Variable $s represent?

What does the $GLOBALS['s'] variable contain? It looks like an empty array, but what would it normally hold? I've encountered it in a tutorial: The WordPress Theme: Single Post, Post Attachment, &...
0
votes
2answers
547 views

problem loading stylesheets to wp_head dynamically

I'm trying to create a wrapper shortcut function to register and load stylesheets in the header. currently, the function loads this css file src: http://my.test/wp-content/theme/css/.css I, ...
0
votes
1answer
221 views

Getting values from options page to css

i got an options page that needs to affects a certain (for now) css value.. i have about using php variables in css and creating custom global variables in wordpress but havent something easy enough ...
0
votes
1answer
16 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
70 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
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 (%...
0
votes
1answer
148 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
217 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
2answers
176 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', '...
0
votes
1answer
231 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 ...