Linked Questions

1 vote
1 answer

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() { ...
71 votes
5 answers

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 ...
67 votes
6 answers

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.
23 votes
3 answers

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 ...
0 votes
1 answer

Using "add_image_size" to register custom image sizes inside plugins not working

I noticed that most examples of add_image_size() is done via the after_setup_theme hook. Which means, for it to register, one has to switch theme and reactivate the theme. Which is not ideal for me as ...
0 votes
1 answer

Is functions.php in themes applied to all templates?

I've been reading the theme developer handbook for a bit and maybe I ended up with one too many questions on wordpress theme development. I haven't done any theme/php development in a very long time ...
8 votes
1 answer

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, ...
2 votes
2 answers

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 ...
2 votes
4 answers

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?
-1 votes
1 answer

Need to use an external variable inside a function

Need help with a theme I'm working on. Basically I have a variable that's set early called $type <?php if ( preg_match( "/^kssm-/i", $licensekey )&& preg_match("/@/i", $licensekey) == ...
0 votes
0 answers

How can I get the Post ID and Post Type within a Must Use Plugin?

I'm trying to get the Post ID and the Post Type inside of my MU Plugin; functions like: get_the_ID() and get_post_type() return false, instead of the desire values. I read that many functions are ...
0 votes
0 answers

How to use a shortcode of a plugin in another plugin php file

I'm trying to implement reservation function in my web with two plugins of wordpress. Two plugins are reservation plugin and payment plugin, respectively. Reservation plugin has some steps for ...
0 votes
1 answer

Only allow a plugin to work on a specific page? (Prefer not to use a plugin)

I know that there is an 'answer' to my question here but it has -2 votes. As the title of the question suggests - I am trying to allow a WordPress Plugin to ONLY execute on a template. What is the '...
4 votes
2 answers

$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 ...
0 votes
1 answer

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 ...

15 30 50 per page