Archived topic
Using Element Hook to add a function?
3 replies · Started by Andre on October 14, 2021
Hello,
I'm using the plugin Code Snippet to add 2 functions to my website (removing author links and excluding some post from archive pages).
Is it possible to use an Element Hook instead of this plugin to add this functionality to my website?
Sincerely,
Andre
Hi Andre,
It's possible but it has definitely not recommended.
Hook Element is for presentation purposes only. It's meant to hook HTML in. Not modify/filter things.
While you can run PHP snippets in it, we only recommend placing simple PHP snippets in it like printing values.
Removing author links may require remove_action() function and excluding posts may require pre_get_posts filtering and these kind of snippets should stay within a code snippets plugin or child theme's functions.php.
Hi,
It makes sense, I'll leave it as it is right now with the Code Snippet plugin.
Thank you for the quick reply!
André
No problem. Glad to be of any help. :D