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
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
5k views

category__not_in and id values from variable

How can I set the values for category__not_in from two variables. On my example I just hardcode the ID of each category to exclude, but... how can I pass these values from some variables ? $...
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
120 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
363 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
2k views

Can't Access Sessions or Variables through pages

So I'm trying to use a session to move a variable through pages. For some reason I literally cannot access anything from index.php to archive. I declare my session at the very top of my header.php ...
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
550 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
226 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
2answers
6k views

Get current page id, title, url, etc

Sorry but I get lost on Wordpress's codex. I am trying to add a mail this page sharing link and want to include some info from the page. In pseudo code is this possible? <a href="mailto:?subject="....
0
votes
1answer
15 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 $...
0
votes
1answer
22 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 ...
0
votes
2answers
45 views

Insert page content into another page with a changed variable

I'm trying to use this simple code to insert page (1) content into another page (2): <?php $id = 216; $p = get_page($id); echo apply_filters('the_content', $p->post_content); ?> So far so ...
0
votes
1answer
19 views

Pass Variables or Variable Place-Holder from Editor to PHP

I'm building a method for my client to construct a message content to be sent with wp_mail. Within that I'd like them to be able to choose variables, for example the message might look like this in my ...
0
votes
1answer
191 views

Undefined variable error in new function

I wanted make function to count the time last the user read the article but after putting it in fuctions.php I see this error: Notice: Undefined variable: post in /home/karnetac/public_html/wp-...
0
votes
1answer
29 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
211 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
23 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
330 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
529 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
531 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
431 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 ...
0
votes
1answer
212 views

How can I programmatically change a MySql variable (foreign_keys_check)?

I am creating custom tables from a plugin. Foreign keys are required. To be safe, I'm want turn off foreign_keys_check before issuing maybe_create_table(). This codes is what I have to check ...
0
votes
1answer
135 views

Custom Post Type Object - Undefined Variables

I am writing a plugin that uses a class in order to generate custom post types. I am using PHPStorm and it is reporting that some variables are undefined. For Example... class Custom_Post_Type { ...
0
votes
1answer
3k views

Send value of PHP variable in template via hidden field in a form

In a page template, I have a variable that stores an array of post IDs. I would like users to be able to send that data in an email, by clicking a button on the front end page of that template. The ...
0
votes
1answer
95 views

How to reference PHP in Javascript

I'd like a php link for my Wordpress attachments to appear in part of a javascript function, but my below attempt does not output any text: var link = "<?php echo wp_get_attachment_link();?>"; ...
0
votes
1answer
79 views

Wordpress Alphabetical Sort Loop Issue

I created a site for my company recently and previously, I was simply manually changing a variable and had the same code copied and pasted 26 times one after the other, but I figured I should loopify ...
0
votes
1answer
5k views

Store and Change Session variable - PHP SESSION VARIABLE

I would like to change a session variable which will change another variable in two different places. One variable determines what posts the user will see which is in my custom post archive file(...
0
votes
1answer
61 views

Retrieve custom variable

I created a simple plugin for changing the body background colour. But I cannot retrieve the variable that the colour is stored. <?php /* Plugin Name: My Plugin Version: 1.0 License: GPL2 */ /** ...
0
votes
1answer
518 views

Overide Variable in Child Theme

I am trying to change the h1 tag in the head of my child theme from "Blog" to "Resources". The parent theme enqueues files with require_once and get_template_directory so it's very difficult to ...
0
votes
1answer
153 views

Assigning a Setting to a Variable and Using it in an if Statement

Is it possible to assign get_theme_mod('dds') !=='false'; to a variable and include it in an if statement instead of typing the whole thing? This is the if statement I am dealing with: $DDS = ...
0
votes
1answer
851 views

Wordpress custom widget undefined variable notice

I am developing a theme and I have created a custom widget for it. When I turn on debug mode I get the following notices, NOTICE: wp-content/themes/integral/inc/widgets/feature_widget.php:92 - ...
0
votes
1answer
88 views

Is it advisable to use $post->comment_count instead of get_comments_number( $post_id )

I was learning from the WordPress codex about global variables and after var_dump($post) I found out that $post has a property called comment_count I was wondering whether I can directly use $post-&...
0
votes
3answers
606 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
374 views

echo var into wp_query

Im trying to echo out a value grabbed from a ACF field but I think im doing something wrong, could someone help me? <div class="news"> <div class="container"> <div ...
0
votes
2answers
120 views

how can I include some custom variable from functions.php?

For example, if I add this code to functions.php: $mysite_address_url="http://my-site.com"; And then add this to one of my .php template files(like index.php or header.php): <?php echo($...
0
votes
1answer
630 views

Dynamically adding filters

I have a function that I'm trying to get an array in it to use in a callback to dynamically add filters. Here is the function that I need to retrieve the array keys from ( in the $classes variable ): ...
0
votes
3answers
438 views

Action 'init' function doesn't return variable

I have a function which checks if $_POST is set (a form which submits to the same page). I need to have it initialized before the page is loaded because the function will do a header redirect if the ...
0
votes
1answer
45 views

Easy reading or transfer of data from posts?

Plugin usually transfer data using code like [espro-slider id=21] , is there a short way to read it or do they use regex to read it. If not is there a short way to define variable in post and use it ...
0
votes
1answer
2k views

Query Products & Store IDs in array

I'm attempting to query Products in WooCommerce and return their IDs as an array that can be used to filter conditionally. I'm using ACF Pro to add custom fields into the product, for which I'm then ...
0
votes
1answer
160 views

Pushing Category and Publish Date to Google Analytics

I have found an interesting article about tracking variables with JS based statical system (for example Google Analytics). The article writes examples like: _gaq.push('setCustomVar', 3, 'pubDate','...
0
votes
1answer
181 views

Where's the explanation of the TinyMCE's vars in the WP core?

I am modifying my TinyMCE editor for my users, and I'm using the example in the docs as a starting point. function my_format_TinyMCE( $in ) { $in['remove_linebreaks'] = false; $in['...
0
votes
3answers
3k views

Creating Wordpress Shortcode with Variable

please forgive me I'm relatively new to PHP... I would like to create a shortcode called [city-name] and have tried placing the following code in my functions.php file: function get_city_name() { ...
0
votes
1answer
59 views

Is it possible to pass variables to WordPress externally?

I would like to know if it is possible to pass json variables from a form which is located outside WordPress? This is the situation: The user fills a form located on x server. Then his answers are ...
0
votes
1answer
732 views

Trying to create an edit page link?

Using a plugin and have created a page that offers more fields in a spreadsheet format. To add these extra fields you simply click edit on the row you want to edit.... Now when I am in the plugins ...
0
votes
2answers
1k views

Passing PHP Variables to AJAX Loaded Pages

I have a blog that shows 9 blogs posts per page, with each additional page of blog posts automatically added using the Infinite Ajax Scroll plugin. Every time a blog post is successfully queried the ...
0
votes
1answer
634 views

How can I assign bloginfo path or thumbnail path to a variable and call it in markup?

In my head this sound right. I check if the post has a thumbnail. If it has, I assign the post thumbnail to a variable that I call as the source for my background image. If the post does not have a ...
0
votes
1answer
8k views

Enter a variable in the 'category_name' parameter

Is it possible to use a variable for the 'category_name' parameter? I have three pages: red, yellow, and blue. I have multiple posts that are categorized in three categories: red, yellow, and blue. ...
0
votes
1answer
1k views

Passing variable as permalink URL

I've been trying to adapt the rewrite functions described here with little success: Passing variables through permalink structure WordPress permalinks and custom $_GET Variables The structure of the ...
0
votes
1answer
50 views

Declaring a var, placing it in a query and using the output of the query?

So i'm wondering if it's possible to declare a variable that you'd place in a query to then use it in a update_post_meta function? This is how I tried to do it. First off I made a connection to ...

1 2 3
4
5
7