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
vote
2answers
186 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: ...
0
votes
2answers
504 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 ...
1
vote
1answer
494 views

What is the best way to store custom variables

I need to store the id and secret key of my FB application. I don't want to write them directly in my template. What do you recommend ?
0
votes
0answers
94 views

Passing user first and last names from external db to WordPress user first and last names using session variables?

This may be a little convoluted, but here it goes. I don't let users register on WordPress to access my member site. I have an outside registration/login system set up and want to continue using ...
0
votes
1answer
177 views

Custom post type archive page for multiple post types

Hi I am working on a archive page which I can use for multiple custom post types. I need to make a variable in the $args array which can change to the post_type name on the basis of <?php ...
0
votes
1answer
625 views

How to create custom variables in the wp-config

I would like to add some custom config variable in the wp-config file (not in the functions.php). Then, I need to access to these variable in my templates. What is the way to do it ?
1
vote
1answer
519 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
142 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() ...
0
votes
1answer
144 views

Intercepting $_GET variable from custom pagination

I have a custom pagination using a form with the get action so I can have a page jumper box. Everything works until you enter something that is not an actual page. Examples are negative numbers, text ...
0
votes
1answer
78 views

Variable Not Working Inside is_author() Array

I'm using a plugin (User Groups) to separate out users into, well, groups, and I need to figure out a way to create a conditional to check if an author is in a certain group. So, using get_term_by and ...
0
votes
1answer
224 views

wp_localize_script not create variable in head section

I try to make an ajax function in wordpress and I enqueued my script and declared my variables like this in functions.php: function my_enqueue_scripts() { wp_enqueue_script( 'load_post', ...
0
votes
1answer
2k views

Passing a variable into Contact Form 7 [closed]

I have been looking for a solution to this, have seen some sort of add on called dynamic text but I don't think that suits my needs. Basically, I have a multi dimensional array. Basically what I want ...
0
votes
1answer
34 views

Difference in Get Variable Location

I have noticed that in some instances in WordPress (such as in my custom post types), GET variables appear as following in the URL: www.url.com/events/cool-event?action=edit&message=1 However, ...
0
votes
1answer
33 views

Variables posting twice

I wish to create a new variable as described in the codex, but on submission of the URL the variables are submitted twice to my function I have tried this within a plugin also a the function.php. I ...
0
votes
1answer
84 views

Cron Job variable not accessible

I am currently running a cron job on my cPanel to update a variable containing exchange rates, how can I make this variable available to functions and pages in my wordpress site? My command in cPanel ...
0
votes
2answers
359 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
94 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: ...
6
votes
2answers
151 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 ...
-1
votes
1answer
3k 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
1answer
267 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
59 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
637 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
70 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
706 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
102 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
43 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
3answers
334 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
77 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
265 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
229 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
111 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
144 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
71 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
90 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
998 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
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 ...
0
votes
2answers
7k 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
86 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
292 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
110 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
175 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
1k 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
94 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 ...
3
votes
1answer
950 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
526 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
152 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
797 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
333 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
687 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
743 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 ...