[Support request] Can I use Elements as shortcut?

Home Forums Support [Support request] Can I use Elements as shortcut?

Home Forums Support Can I use Elements as shortcut?

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
  • #2361317

    Can I use Elements as shortcut?
    I mean Can I use Element manual in specific post or page? by paste the code in post?

    Customer Support

    Hi there,

    What kind of element are you talking about?

    If it’s a block element, why not save it as a reusable block, so you can add it to post/page via block editor?

    If it’s a hook element, what will the content be?

    Let me know!


    It is code of JavaScript and i need to add it in 200 posts, then if I need to change this code i want to change it in one place, not manual in every post of 200 posts.

    Customer Support

    Hi Neronet,

    A Hook Element would be perfect for this.

    Just add the Script through the hook, and set the display rule location to your preference.

    Reference: https://docs.generatepress.com/article/hooks-element-overview/


    A Hook Element you dont give me shortcut to put it where I want in post; right?
    I need shortcut to use it wherever I want in post. t.ex I have age calculator code (html,java,css) and i want to use it in specific posts not all the category.
    After 1 year i want to update this code so I have to edite about 75 articles manaul, it will take time, so i need edite the code in one place and it will change in every have this code.

    Customer Support

    Where exactly do you want it to appear in posts? Would the location in each posts be identical?


    not specific location t.ex here

    Customer Support

    For one, you can add a Portable Hook:

    function portable_func($atts, $content = null) {
          return ob_get_clean();
    add_shortcode('portable-shortcode', 'portable_func');

    Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets

    Now, you can add [portable-shortcode] Shortcode in your posts, and then use hook portable_hook in your Hook Element.

    This should hook your script in your preferred location.

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