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 ...

learn more… | top users | synonyms

10
votes
2answers
3k views

What are all the Properties of the WordPress Post Object?

(Moderator's note: Title was originally "What are all the variables in the wordpress post object?") Does anyone know the variables that are stored in the WordPress Post object?
6
votes
2answers
148 views

Wordpress variables and memory

When checking get_defined_vars() on an empty template file my theme loads over 70000 lines of output. Before even including elements on a page all of this is loaded. Is this correct? Is there any ...
6
votes
3answers
3k views

How to Pass External Variables to Filters/Actions

I find myself needing to pass custom data to a filter provided by a 3rd party plugin. All of the ways I've seen to do this are really complicated and hard to wrap my head around. Take this example: ...
4
votes
4answers
2k views

Where to get information about array fields in $_REQUEST?

I just started to learn PHP and doing things with WordPress and I am a bit confused about information in Codex. Was told that Codex got all info I required but I got stuck with it. What array fields ...
3
votes
1answer
579 views

Variables declared in header not available in other includes

I have a var set in my header.php file: $myBool = false; and in page.php, I try to echo it: echo $myBool; But the variable is never set. This doesn't help either: global $myBool; echo $myBool; ...
3
votes
1answer
3k views

How do I make my function add variables/values to the $post object?

How do I add $tzDesc and $tzEmbed (and other variables) to the $post object in the following function so that I can display the values in my theme files by inserting <?php echo $tzDesc; ?>? ...
3
votes
2answers
730 views

Why does Wordpress Pagination Remove the Spaces from my GET Variable?

I'm passing a GET variable at the end of my URL's as my search parameter. When I do a regular search, everything works fine: www.mysite.com/?find=my+search However, when I click over to the second ...
3
votes
1answer
705 views

How to pass on Google Adwords gclid variable to other pages

i need to track if people filled out any of my forms on my wordpress blog if they where coming from a Google Adwords ad. There are many forms on my website like for booking a demo presentation, ...
2
votes
3answers
547 views

where to include a php file

I have a php file with some variables which I would like to use. When I include it in the header.php the variables in that file are not recognized at footer.php and some other places. Where is the ...
2
votes
3answers
1k views

How do I pass an argument to my custom walker?

I've set up a custom walker, and it works as desired when I hard code my variable. What I want is to be able to call my walker and pass it a variable that is used in the walker. For example: ...
2
votes
1answer
1k views

How to var_dump nav menu items from anywhere?

I wanna preview all the fields that the nav menu $item array holds. Is there a function to fetch it from anywhere and place it inside var_dump?
2
votes
2answers
6k views

Using $_GET variables in the URL?

I need to generate a simple error message on a page by passing a variable through the URL. The URL is structured as follows: http://site.com/parent-category/category/?error=pause I'm sure it's the ...
2
votes
1answer
47 views

How do I know what variables are passed in a filter/action and what their meaning is?

Something I have seen several times now and I don't understand is the following: In a theme's functions.php a function is defined and then attached to a hook, like so (simplified example): function ...
2
votes
2answers
673 views

How to pass data around?

I have different menu items. When the user clicks on a menu item, I want them to go to a particular destination. Each menu's destination has a different background color. I'm thinking that I can pass ...
2
votes
2answers
58 views

WordPress filtering utm_ GET variables from url unless logged in as admin, not sure why?

So I am having an issue where I can't pull variables such as mysite.com/?utm_campaign=testing unless I am logged in as admin or editor. When logged out and just a regular users I can't grab any ...
2
votes
1answer
732 views

How Can I Access a PHP Variable in Another PHP Function

I'd like to use the $atts variable from the lax_google_map_maker() function in lax_google_map_init(). How do I access it? I tried to 'globalize' it, but for some reason it didn't work. function ...
2
votes
1answer
462 views

dynamic external javascript generated using php

How to write an external javascript file with dynamic variable values generated using php from wp db values? So instead of using wp_localize_script for inline js variables, I'd like to use ...
2
votes
1answer
851 views

Moving variables from one page to another

How can I link to another WordPress page but move variables to it as well (preferably not through the address bar)? For instance, I have on one page a list of shops in which a user should be able to ...
2
votes
1answer
2k views

Take Variables Set in Functions.php and Echo Them Inside My Custom Post Template

I have the following function set up in my functions.php file to allow my custom post type "Slideshow" to work. add_action( 'the_post', 'paginate_slide' ); function paginate_slide( $post ) { ...
2
votes
1answer
150 views

Using Wordpress public query variables

Good morning. I am trying to query various Wordpress pages, using public query variables, for example http://dmkim1979.ru/?p=37 // single post http://dmkim1979.ru/?page_id=40 ...
2
votes
3answers
986 views

How to make variables in URL look like the permalink structure?

I've been looking for the answer to this everywhere but with no success and that's why I'm asking here. I don't even know if the question is the right one. In any case, I'll try to explain. I have ...
1
vote
4answers
2k views

How to tell if $query_var isset?

I tired to use isset($queryvar) but that didnt work, so I implemented my own function qv_isset, but it runs into a problem when $ch is set to 0. $cls = get_query_var('cls'); $ch = ...
1
vote
2answers
92 views

How do you Query posts with nothing in common?

We can get multiple posts manually in a page, but that's generated in a template, AFTER the default query returned something else (page/post, etc) How do you query multiple posts in a public query, ...
1
vote
1answer
4k views

Custom page with variables in url. Nice url with add_rewrite_rule

Using WP3.1 I Have a custom page with a WP_Query and the query gets dynamic variables from the url. And i want safe variables and clean urls. Example: ...
1
vote
2answers
641 views

How to declare a JS variable in an AJAX call

I'm using: wp_localize_script( $handle, $namespace, $variables ); to declare some variables before the initial AJAX call is made, but I imagine I can't do the same thing again within a callback ...
1
vote
1answer
151 views

Why does a variable work on the front page but return NULL on all other pages?

Hey all. For my theme, I have multiple sidebars. Each sidebar file has a variable of $sidebar_id assigned to it. So, for sidebar-1.php, $sidebar_id = 1, for sidebar-2.php, $sidebar_id = 2, and so on. ...
1
vote
2answers
90 views

Using Multiple Queries of “home_url” vs. Calling a Variable Multiple Times

Question Since I am using multiple instances of home_url() in one page template, I was curious if the following method would speed up my page load time. My method is to store the output of home_url() ...
1
vote
1answer
107 views

Can wp_list_comments output into variable?

Is there any way how to output wp_list_comments() into a variable? Something like $output = wp_list_comments(array('reverse_top_level' => false ), $comments); I am writing a plugin and it would ...
1
vote
1answer
913 views

Use of global variables within plugin [closed]

I am creating my first plugin ever and I found my self having to call the same option variables within various parts of the same page therefore I sought for a solution and stumbled upon global ...
1
vote
2answers
98 views

Putting PHP variables into javascript [duplicate]

I've created a simple theme options page for my site. The options page contains three input fields. I can output the the fields by using get_option. The three fields are called using the following: ...
1
vote
1answer
135 views

WP_Query Variable inside Array

The array below with "'taxonomy' => 'age'" isn't working, if I copy and paste the array "array( '19', '20' )" in place of the variable it works fine. I just started picking up PHP so go easy on me :) ...
1
vote
2answers
237 views

Retrieve the template directory URI via global or get_template_directory_uri() every time?

One Wordpress function I happen to use frequently is get_template_directory_uri(). While I tried to minimize or avoid its use where I can, I still happen to have more than one call to this function in ...
1
vote
1answer
789 views

stop the_permalink printing and save as variable?

Is there a way i can get the_permalink as a variable? I need to build an info window with it but it wont appear in the $infoWindow variable... <? $link = the_permalink($post->ID); // prints ...
1
vote
2answers
89 views

Access the environment of an admin page from another admin page

I've been busy thinking about a problem, and so far I didn't find a solution to it. The abstract scenario On admin page A, I would like to print the value of a (global) variable—in the context ...
1
vote
2answers
236 views

Passing values from a widget to a function within a plugin

I have a plugin that is built with many widgets. A widget's bundle. Each widget creates it's own custom CSS code. Instead of having messy source code where I display 15 different sets of inline CSS ...
1
vote
1answer
380 views

How do i calculate the total of values of custom fields in custom post types?

So the title is a bit unclear, but here is what i have: Custom post type: Projects Custom post type: Investments        + Custom field: Amount And i have one page ...
1
vote
1answer
98 views

how to put a custom field value in variable

function zh_get_invoice_round_off_number() { global $post; return get_post_meta($post->ID, 'invoice_round_off_number', true); } function zh_invoice_round_off_number() ...
1
vote
2answers
1k views

How can I Add a variable PHP in the Menu Nav

I want to add a variable in the Menu, for passing a value in all my page. The purpose is to retrieve a value for transport to another web site (from my website links) to the tracking, this value ...
1
vote
1answer
578 views

Use <?php echo $_GET['ref']; ?> to track referrals

I am setting up my wp site and i have it setup like this www.mydomain.com/?ref=AFFILIATEID thats alright if they land on the page they are directed to but if they go off page onto another one, how do ...
1
vote
1answer
608 views

Pagination for category slug returns 404 when page >= 2

I have a custom type and the slug is: 'rewrite' => array('slug' => 'blog/%blogs_tax%'), And after register_post_type() I have a function to rewrite the slug variable. I works fine, but I ...
1
vote
1answer
162 views

Use post object from first query in second query

I have a post ID stored in a variable from my first query and I'd like to use that to highlight the post with the same ID in my second query, but it's not working. First loop: <?php if ...
1
vote
1answer
161 views

Echoing a variable inside a function

In the interest of automation, instead of making a long list of code like this <td valign="top"width="50%"><p><label for="Facebook"><strong>Facebook ...
1
vote
1answer
207 views

Using $themename Variables

Is it a bad idea to set your themename and shortname as variables to be used in the various functions of a theme? Example: $themename = mytheme; $shortname = mth; /** * Get our wp_nav_menu() ...
1
vote
1answer
363 views

Can you keep session data for visitors?

I read that you can use session_start() in config.php, but that it is not recommended. I have a form where a user fills out their name and submits. On confirmation of the submission they land on a ...
1
vote
1answer
341 views

Append varible to url or set session

I just wrote a little plugin that detects if the user is on a mobile browser and if so detects them away from the WordPress site to a mobile (simple) version of part of the site. As I got to ...
1
vote
1answer
897 views

How do I pass variables into short-code enabled Post Snippets in Wordpress 3.0?

I am using a plugin called Post Snippets. According to the documentation, it can substitute variables, such as {url} within the snippets. http://wordpress.org/extend/plugins/post-snippets/ I am ...
1
vote
0answers
23 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
147 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
115 views

Track usernames with piwik

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
773 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 ...