Hi there! Let’s see if I can help you understand how priority works.
Priority is important when the patterns used to match different handlers might return true for the same route. For example:
/:taxonomy/:slug both will match the route
To go into more detail, in this case we have a more specific pattern (
/category/:slug), only for the taxonomy
category, and a more general pattern (
/:taxonomy/:slug), for any other taxonomy, therefore you want to give the more specific pattern a higher priority so it’s tested against the route before the general one, because once a pattern matches, no other handlers will be tested against that route.
If the handlers can’t collide between them (like
/tag/:slug), they can have the same priority because there is no risk of one handler being used with the wrong route.
The lower the number, the higher the priority. Consequently a handler with priority 5 will be tested before a handler with priority 10.
The reason why the default handlers have a priority of 20 is because it’s impossible to foresee the cases a developer might run into so, this way there is room for custom handlers to run before or after the default ones as needed.
You hardcode the priority on your custom handler. This mechanism is not something exclusive to Frontity, priority is used in the same way with WP actions, which is one of the reasons it was adopted in Frontity, we thought it would be familiar to people coming from WP.
No, they run in the order they are defined in the array.