Site logo

[Support request] Can I insert element (hook,block)in post as shortcut?

Home Forums Support [Support request] Can I insert element (hook,block)in post as shortcut?

Home Forums Support Can I insert element (hook,block)in post as shortcut?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #2455895
    Neronet

    Can I insert element (hook,block)in post as shortcut?

    #2456158
    David
    Staff
    Customer Support

    Hi there,

    do you meant a Shortcode ?
    If so, add this PHP Snippet to your site:

    
    add_shortcode('portable_hook', function($atts){
    	ob_start();
            $atts = shortcode_atts( array(
                'hook_name' => 'no foo'
            ), $atts, 'portable_hook' );
    		do_action($atts['hook_name']);
    	return ob_get_clean();
    });

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

    Now think of a name for your hook eg. custom_place_in_content

    And you can then add the shortcode for it to your post:

    portable_hook hook_name="custom_place_in_content"]

    Now in your Element, you can set the Hook to Custom and in the field add your hook name.

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