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.

custom hook

  • Hello,

    is it possible to creat a custom hook after the first block of the content?

    thanks
    angel

  • Hi there,

    that depends what the first block of content is , and whether you want to manually insert the hook or dynamically insert the hook.

    For example:

    a. manually insert a hook using a shortcode

    this PHP Snippet:

    
    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();
    });
    

    And you can add a shorcode like this to generate the hook and name it as you want:

    [portable_hook hook_name="my_custom_hook_name"]

    b. dynamically insert the hook into the content.
    see my reply here:

    https://generate.support/topic/google-ad-before-first-h2/#post-113534

    That inserts a custom hook before the first H2 on a page.

    Let me know what you require.

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