Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
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`.
0
votes
Accepted
Global page ID variable empty error
it as soon as wp has queried and generated some post/page data;
This is my final solution, where I used add_action( 'template_redirect', 'nb_setup_globals' );
Here is the final code:
/**
* Setup globals … */
global $nb_id, $nb_view, $nb_page;
function nb_setup_globals(){
global $post, $nb_id, $nb_view, $nb_page;
// Set default vars for globals
$nb_id = $post->ID;
$nb_view = 'front …
0
votes
1
answer
1k
views
Global page ID variable empty error
Currently I am doing it like this:
/**
* Setup globals
*/
global $nb_id, $nb_page;
$nb_id = get_the_ID();
// Prepare & set fallback
$globals_array = array(
'nb_id' => $nb_id,
'nb_page' … => array(
'id' => $nb_id,
'end' => 'front',
'name' => 'home',
'type' => 'page'
)
);
// Set each value from globals array as global $var;
foreach ($globals_array …