-
Hernan
Hello,
I have a somewhat noob doubt. GeneratePress Elements is clearly a powerful tool, but since it can run php I’ve always wondered if it can replace what we usually do in functions.php or plugins like Code Snippets
Right now I’m trying to declare a shortcode in a costum post type (and placing the shortcode wherever I want) and it works without problems. The advantage is that the code would be executed only where it is necessary
Is there a reason why one should prefer to work in functions.php or Code Snippets?
Thanks greetings !
-
Hi there,
but since it can run php I’ve always wondered if it can replace what we usually do in functions.php or plugins like Code Snippets
The simple answer is no. The Block Element – Hook module should only be used when the content is inserted into a hook:
https://docs.generatepress.com/article/hooks-element-overview/A shortcode should be declared in Code Snippets or
function.php
of the child theme.You can add a conditional tag if needed: https://codex.wordpress.org/Conditional_Tags
I hope this helps 🙂
-
Hernan
I understand, it’s better to do things right
Thank you very much for the reply
-
No problem 🙂
- You must be logged in to reply to this topic.