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

-1
votes
1answer
1k 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 I ...
0
votes
0answers
172 views

Why won't the action hook wp_head won't accept parameters?

I'm working on a plugin that adds scripting to the head using add_action('wp_head',..); I have to pass a variable to the function to get my desired result. To test this I'm simple "echoing" out the ...
0
votes
0answers
43 views

Displaying posts by year

I'm trying to display posts on the homepage from the current year only. I am using the following: <?php if ( is_front_page()) { ?> <?php $current_year = date('Y'); ?> <?php ...
0
votes
1answer
321 views

No access to global variables?

In main.js, I have a script, which is sending an ajax request to script.php. $.ajax({ type: "POST", url: "wp-content/themes/roots/script.php", data: registerdata, success: ...
0
votes
1answer
54 views

How to use shortcode inside of shortcode in theme

I am trying to place a shortcode inside another shortcode within a page template, however the various attempts I've made seem to not do anything. Here's how my code looks now - <?php echo ...
0
votes
2answers
384 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
0answers
235 views

Use $_GET with permalinks on page

I'm currently trying to use a $_GET to populate a MySQL query with in a URL on another page within a Wordpress site. URL sample: <a href="http://site.com/file.php?alabama">Alabama</a> ...
0
votes
2answers
64 views

Using Output from one Function and calling it into another

I'm trying to get my head around a fairly simple concept in PHP but I'm pretty green. I have a function.. function pa_insertPage($atts, $content = null) { // Default output if no pageid given ...
-2
votes
1answer
40 views

How do I echo saved data outside the function?

I know the data I want is stored as $lineOne and I can echo that inside the function. But I want to get the data outside of the function. I've tired: $lineOne; $instance['lineOne']; Here's the ...
0
votes
1answer
254 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
57 views

add_menu_page() with variable function

How can I use add_menu_page() functions some variable function ? add_menu_page('My page','My page','manage_options','my_page', 'func' ); $func = function() { echo "Done !"; }; I know I can ...
0
votes
1answer
178 views

Shortcode with multiple variables

I'm trying to create a shortcode to insert the Pinterest button with variables manually in posts. This is the code I've arrived at after reading various posts and grabbing the code from Pinterest. I ...
0
votes
1answer
131 views

How to access a variable on all page?

I added a variable to my functions.php file: $options = get_option( 'simple_options' ); I can access to this variable on every page, but If I call it in the footer.php it's not working. How to fix ...
0
votes
1answer
69 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 ...
1
vote
1answer
123 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 :) ...
0
votes
1answer
57 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
55 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
2answers
685 views

Can't get options with $data['variable']

Can't get options with $data['variable']. (I'm use SMOF - Slightly Modded Options Framework) For example in the header.php (index.php, footer.php, etc.): global $data; $logo_type = stripslashes( ...
1
vote
2answers
894 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 ...
0
votes
2answers
4k views

How to set global variable in functions.php

I want to be able to echo the URL of the featured image of a post and after looking some on the web I found the following which works fine when I put it in a loop in my front page template. <?php ...
0
votes
2answers
80 views

Passing variables trough 2 pages

I am creating a plugin. In this plugin I have shortcodes that provide some logic and content for pages. This way I have created 'Page A' and 'Page B'. Both of the pages will redirect user to external ...
1
vote
2answers
211 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 ...
0
votes
1answer
97 views

About redundant code when I use shortcode to output the HTML from a variable

I use shortcode to output the following html in a variable, but there are too many redundant code such as br and p tags, how to remove them? Thanks! HTML MAKEUP $return_html.='<div ...
1
vote
1answer
136 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 ...
0
votes
3answers
587 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
2answers
87 views

update_option using variable name

Title may not be clear but I'm using update_option($my_option, $new_order); and for some reason it would not work but if instead I change to update_option('my-option-name' $new_order); it works. I ...
2
votes
1answer
555 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, ...
0
votes
1answer
447 views

Using custom url parameters in a page

Im trying to create a custom image galleri that retrieves images from posts as can be seen here http://kurdaktuellt.se/galleri/ problem in hand is that I'm trying to make the url somewhat user ...
0
votes
1answer
132 views

jQuery dialog prints HTML-Tags under Wordpress

i need some help. I am using wp_localize_script in my Wordpres_Plugin. Inthe documentready-function i use this Code to bring the Message up: $('#button-setup-league').click(function() { $( "#dialog ...
-2
votes
1answer
580 views

Use ajax response in PHP function

Ok, so I'm working on a plugin and just ran into a problem. Here's what I'm doing: 1. Using a metabox with Plupload to upload an image to an upload dir in the plugin folder. 2. Upon upload success a ...
0
votes
1answer
224 views

assign the returned value of wordpress function to a variable?

Why can't I store wp_list_categories in a variable? $wplist = wp_list_categories( array ( 'taxonomy' => 'ntp_package_type', ...
1
vote
1answer
513 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
507 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 ...
0
votes
1answer
443 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, ...
1
vote
2answers
91 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, ...
-2
votes
1answer
82 views

Using Form to alter PHP variable [closed]

I'm pulling custom posts by their meta_key using this function: <?php $args = array( 'numberposts' => 10, 'meta_key' => 'allvotes', 'orderby' => ...
0
votes
1answer
93 views

Extracting a variable from a permalink

I used the "Edit Author Slug" plugin to change the author base to /newbase . In the functions.php file, I added a new node to the toolbar (View Profile) that when clicked points to ../newbase/johndoe ...
-2
votes
1answer
270 views

How do I access variables outside a function [closed]

I have a custom function which defines a bunch of variables. I would like to be able to call this function from inside a loop so I can have access to all its variables, like so: functions.php ...
0
votes
1answer
389 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
732 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 ? ...
1
vote
1answer
148 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
0answers
97 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 ...
0
votes
1answer
414 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: ...
2
votes
3answers
878 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 ...
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: ...
0
votes
1answer
72 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
1answer
200 views

Not passing correct value to get_post_ancestors?

I've got a custom plugin that creates a menu in the sidebar. I need to be able to specify that, if a particular custom post type is current, the menu displays as if it were on a specific page (so ...
0
votes
2answers
144 views

How to use variables from widgets in other pages?

I have a widget where I set some custom url's like register or login. I want to use those variables declared in a widget outside of the widget, in other pages (page templates). How can I save or use, ...
2
votes
1answer
937 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?
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 ...