Linked Questions

71 votes
5 answers
51k views

Is there a flowchart for WordPress loading sequence?

So like WP must load series of files from, index.php -> ... -> wp-header.php -> ... ->functions.php ...and so on upon execution. Also there must be a similar flowchart for functions ...
laggingreflex's user avatar
67 votes
6 answers
58k views

How to get WordPress' hooks/actions run sequence?

In what order add_action hooks execute? i.e. init wp_head wp_footer after_theme_setup etc... ??? ??? ??? EDIT: I've also posted my solution.
T.Todua's user avatar
  • 5,810
23 votes
3 answers
39k views

What is the very earliest action hook you can call?

After the solution to this question was to get a function to launch BEFORE the init action is fired by taking the sequence out of its function, it got me thinking, is there any earlier in the WP load ...
Mild Fuzz's user avatar
  • 4,180
10 votes
4 answers
35k views

Consuming an external API in WordPress?

I have a client who has a WordPress website, and he want to extend it to add new functionalities. These functionalities are included in a website I have already done (a kind of search engine over a ...
tahir's user avatar
  • 203
8 votes
1 answer
966 views

PHP code in page template vs functions

I've made numerous WordPress sites, and learned PHP practices that I believe to be right, i.e. functions go in functions.php file, nearly everything in functions.php should be wrapped in a function, ...
tmdesigned's user avatar
  • 1,655
5 votes
2 answers
8k views

When and Where is `global $post` Set and Available?

Usually when people think of the global $post object it's assumed that it's actually set whenever you enter The Loop. I started to play around with how early I could actually call global $post which ...
Howdy_McGee's user avatar
  • 20.7k
4 votes
2 answers
647 views

$wp_query initiation?

I'm wondering when does WordPress initiate its main query which sets the global $wp_query and enable us to use has_posts() and the_post() functions. If I create a page using archive template, how does ...
TurtleTread's user avatar
3 votes
1 answer
291 views

Authoritative answer on which boots first - Plugins or Themes?

I can't seem to find anywhere in the WordPress documentation an authoritative answer on the question on whether a WordPress plugin boots first or whether a WordPress theme boots first. I need to know ...
Sophia_ES's user avatar
  • 155
3 votes
2 answers
3k views

Which functions in theme or plugin load first

I created a plugin to override a theme's function. As I learn that function in plugin loads first but I got an error Fatal error: Cannot redeclare wooc_extra_register_fields() (previously ...
user2834491's user avatar
2 votes
2 answers
440 views

WordPress classes explained

Are there any books, websites or lectures that explain the built-in WordPress classes? I would really like to learn how WordPress works internally. I've dug up the core files on trac and even went ...
Siddharth Thevaril's user avatar
2 votes
4 answers
2k views

How does WordPress call functions attached to a certain action hook before calling functions attached to other hooks

We know that there is a certain order for the execution of callback functions attached to action hooks. How does WordPress decide which action should be prioritized while executing all the hooks?
IAmDhar's user avatar
  • 96
1 vote
2 answers
1k views

What is the callback sent to add_submenu_page() invoked by WordPress?

WordPress tries to be event driven with all it's actions and filters you can hook to. But it also has special functions to create admin pages such as add_submenu_page() which accepts a (callback) $...
Jorge Orpinel Pérez's user avatar
1 vote
1 answer
355 views

Why does add_action() not run when placed in register_activation_hook()?

I have questions about executing add_action() in a Wordpress plugin. I was attempting to insert into the tag via the plugin i wrote. I had this (which never ran, btw) function tt_add_GA4_header() { ...
extensa5620's user avatar
0 votes
2 answers
13k views

What is the proper way to get logged in user id in a plugin?

I need to get logged in user id inside my plugin. Is this the proper way? $root = dirname(dirname(dirname(dirname(__FILE__)))); if (file_exists($root.'/wp-load.php')) { require_once($root.'/wp-load....
PrivateUser's user avatar
  • 3,459
0 votes
1 answer
892 views

Why can't a custom postype be registered with "admin_init" hook?

Why do I need to use the "init" hook instead of the "admin_init" hook? init:fires after the core of the wordpress is loaded but before headers are sent admin init:before any other hook when the user ...
Johnthomas's user avatar

15 30 50 per page