Site logo

Archived topic

Could you explain how priority works?

3 replies · Started by Jusung on February 8, 2023

Viewing posts 1–4 of 4

I found there is priority on elements and I started to use it since I set GTM on my website.

I gave 5 priority for the GTM head code and gave 0 for GTM body code.
I also added Datalayer for view content and I gave 10 priority to it.

Would this be fine? On my end, it works well.
I don't know how it works.

Hi Jusung,

Priority defines what "hook" runs first.

By default, all hooks have a priority of 10.

So, if you set your hook to 1, it will run first before other codes with lower priority.

See here for more info: https://learn.wordpress.org/tutorial/wordpress-action-hooks/#:~:text=Hook%20priority%20allows%20you%20to%20determine%20the%20order%20in%20which%20your%20hook%20callback%20is%20run%20relative%20to%20any%20other%20hook%20callbacks%20that%20may%20be%20registered%20on%20the%20given%20hook%2C%20either%20by%20WordPress%20Core%2C%20or%20other%20themes%20and%20plugins.%20Hooks%20run%20in%20numerical%20order%20of%20priority%20starting%20at%20one.

What you did should be fine.

THank you for expalanation!

I got it!

This archived topic is closed to new replies.