All Questions
Tagged with globals theme-development
8 questions
1
vote
1
answer
1k
views
What is the proper method of using global $post?
I am using global $post multiple times in a class. These are my doubts
Is that a bad practice?
Can it result in slow websites?
What's the proper way to use it inside a class
class Test{
public ...
0
votes
1
answer
1k
views
Global page ID variable empty error
I am creating theme and I have a need to create global variables within theme functions.php file.
Currently I am doing it like this:
/**
* Setup globals
*/
global $nb_id, $nb_page;
$nb_id = ...
10
votes
3
answers
14k
views
What is $post_id? is it a global variable in WordPress?
How can $post_id be used while echoing posts in single.php?
Is it a global variable?
0
votes
1
answer
512
views
Getting the teaser text without overriding global variables
I am trying to make a WordPress theme, following the Wordpress Coding Standards - WPCS. In functions.php, I have a function to get only the teaser (text above the read more-tag). The function works, ...
1
vote
2
answers
761
views
after_setup_theme, Global Variable and Theme Customizer
I am using a global variable that is defining in a function runs in after_setup_theme. This variable is not getting update changes in Theme Customizer.
Let me explain this with an example:
...
0
votes
0
answers
85
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 ...
3
votes
2
answers
1k
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 ...
2
votes
2
answers
1k
views
How should I store global information such as a phone number so that it is editable through the CMS?
Right now I have a p element in header.php containing the address and phone number my client wishes to use for contact info. How can I set this up so that it is editable through the WP admin area so ...