We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [globals]

In PHP globals are variables that are available for every function. WordPress core defines several handfulls of global variables, such as `$post` and `wp_query`.

Filter by
Sorted by
Tagged with
0
votes
2answers
88 views

Save last login date in global before change it?

I use this function to get the last time a user logged in. function jkn_last_login($user_login) { $user = get_user_by( 'login', $user_login ); global $last_login; $last_login = array(); ...
0
votes
1answer
52 views

apply_filters to $GLOBALS

I'm building a onepage website, using the Pootle Page Building plugin. With get_page, I show every separate page on 1 page. To target the Pootle Page Builder content, I'm using the following code: $...
0
votes
0answers
688 views

Setting a cookie in functions.php and it gets deleted when working on an other function

My first function gets the parameters from the URL and sets the cookies: /** Get variables from the URL and set them into the coockie **/ add_action( 'init', 'set_utm_cookie'); function ...
0
votes
0answers
114 views

Popup panel is only displaying 1 entry ignoring all others

I have a popup panel being used for when someone clicks on view bio it will display their bio along with their name and headshot. As of right now I have four members being displayed M1 M2 M3 and M4. ...
0
votes
0answers
66 views

Best way to access variables in template markup

I am making my own mini OOP wrapper for working with wordpress themes. I have a main $settings variable that contains all of the information like definitions, scripts, menus etc.. I then pass this ...
0
votes
1answer
152 views

Editing Global Variables from Inside Functions

I'm working on my first plugin and I have two separate functions inside to accomplish two different task. Each function is added to a different hook, one using actions and the other using filters. ...
0
votes
1answer
26 views

Settings in functions.php used by a plugin

I'm writing a simple plugin and want some settings in an array in the functions.php file. I'm thinking of adding this in the theme functions.php $test = array('haha' => 'hehe'); my_function( $...
0
votes
0answers
59 views

Add notice to add image popup

I have been using the global $pagenow variable to add instructions for users, but I need to somehow hook into the add image popup as I would like to instruct the users on optimal resolution for ...
0
votes
0answers
263 views

How to load post_meta for custom post type via Ajax

I'm trying to load a YouTube video via ajax outside the loop. I have it working on regular pages, but not anything loaded via ajax. A user would click a button, then a YouTube video will load via ajax,...
0
votes
0answers
89 views

Sessions in plugin development?

I'm developing a plugin. At present I have two files. dotmailer.php and dotmailer-add.php. I'm creating a newsletter widget. My dotmailer.php plugin adds an admin menu, with options. It allows the ...
0
votes
0answers
14 views

setting global and using as argument [duplicate]

I've set a global variable in functions.php like so: $cat_args = array('cat1', 'cat2', 'cat3'); and tried to use it in a template file: global $cat_args; if is_cat($args): //do stuff endif; The ...
0
votes
1answer
976 views

Current URL path variable

WordPress has a built-in variable $pagename that will give the current page. I am looking for something that will give the full url including the path before the current page. Details below. I am ...
0
votes
1answer
435 views

Save something to global var in add_filter

I am here again with a strange question. First, I'm using ACF plugin for adding cistom fields. My code looks somethink like that: global $testMe; $testMe = 0; function my_acf_update_value( $value, $...
0
votes
0answers
146 views

Wordpress $GLOBALS and PHP $GLOBALS

Is the php $GLOBALS associative array over written in WordPress with the WordPress $GLOBALS? I have a piece of code that uses $GLOBALS['myvariablename'] to access a global variable. It works in php, ...
0
votes
1answer
193 views

key( $GLOBALS['wp_registered_sidebars'] ) is always showing the same value

I am using this code from another answer add_action( 'dynamic_sidebar', 'wpse_96681_hr' ); function wpse_96681_hr( $widget ) { static $counter = 0; // right sidebar in Twenty Ten. Adjust ...
-1
votes
1answer
9k 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 ...
-1
votes
1answer
71 views

$GLOBALS & global doesn't work [closed]

I have the following configuration: $GLOBALS['x'] = 1; add_filter( 'filter_hook', 'my_function', 10, 2 ); function my_function() { $GLOBALS['x'] = 2; } add_action( 'action_hook', 'my_function2'...
-1
votes
1answer
52 views

Global Handle to Class unavailable in Plugin?

I am writing a custom plugin and calling the plugin functions using short codes on my wordpress page. global $db_handle; below declares the handle to the class 'DBController' global. if (isset($...
-1
votes
1answer
21 views

Wordpress Multisite and site speed and scaleability

We have a multisite wordpress setup like this: domain.com/nz domain.com/au domain.com/us etc. I would like to know the best approach for the best setup so we can give each country the best site speed ...
-1
votes
1answer
217 views

$do_not_duplicate is not working in genesis theme

I'm using Genesis child theme and I am using this function to display feature posts on home page. function modern_motoroids_extra_feature_posts(){ ?> <?php $do_not_duplicate = array(); ?...