Site logo

Archived topic

Why use the plugin "Code Snippets" when Hooks in Elements can be used?

1 reply · Started by Lars on September 1, 2022

Viewing posts 1–2 of 2

It has been recommended by you to use the plugin Code Snippets if I want to implement PHP-code. The more I get used to using Hooks through Elements I realize that everything, in terms of implementing scripts, can be done through there. So why would I want to use a plugin like Code Snippets at all?

A curious question. Thanks!

Hi Lars,

Hook Elements in simple terms are actions hooks. They run at specific points as your page loads, depending on which hook you use. In general, you only use this if you’re running code you wish to run at a specific location.

Otherwise, some code need to run on page load or sometime early as your page loads. If you add a code like add_shortcode in an action hook/hook element, it will be loaded late which may cause issues.

Simply put it, some code won't work in Hook Elements.

This archived topic is closed to new replies.