Elements – block – add via shortcode?

  • Hi Support,
    I want to add a largw parallax photo in the middle of a page and prevent to make it visible for editors. So created an element for it. Now I need to insert it at the right place, I can’t select a hook because none of the hook “places” apply. I want to add the element between other page content blocks. Isn’t is possible to insert the element as a short-code?
    Thanks.

  • Hi there,

    A Block Element with a custom hook paired with a simple shortcode would work well for this. Here’s how:

    1. Create your Block Element with the parallax content.

    2. Under Hook, enter a custom hook name, e.g. parallax_section.

    Element with custom hook

    3. Set the Display Rules to the page(s) where you want it to appear.

    4. Add this snippet to your child theme’s functions.php:

    add_shortcode( 'parallax_section', function() {
        ob_start();
        do_action( 'parallax_section' );
        return ob_get_clean();
    } );

    5. In your page content, place [parallax_section] wherever you want the parallax image to appear.

    Editors will only see the shortcode text in the block editor — the actual parallax content is managed in the Element, which they don’t have access to.

  • Thank you George, it works like a charm!

  • Glad to know, no problem!

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