Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Can Elements replace functions.php or code plugins or is it abuse?

  • 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 🙂

  • I understand, it’s better to do things right

    Thank you very much for the reply

  • No problem 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.