Site logo

[Support request] Hook in the Content Area

Home Forums Support [Support request] Hook in the Content Area

Home Forums Support Hook in the Content Area

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #2597356
    Oppo Gene

    Hi there, I want to place hook in and below the content area

    Thank You
    Looking Forward

    #2597378
    Fernando
    Customer Support

    Hello there,

    Try adding this 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();
    });
    
    add_filter( 'the_content', 'insert_custom_hook', 20 );
    function insert_custom_hook( $content ) {
        global $post;
        $inserted_hook = do_shortcode('[portable_hook hook_name="after_post_content"]');
        if ( is_single() && ! is_admin() ) {
            return $content . $inserted_hook;
        }
        return $content;
    }

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

    After activating this PHP snippet on your site, you can hook things at the end of the content using after_post_content hook.

    #2597427
    Oppo Gene

    this will also works with in the content area?

    #2597458
    Fernando
    Customer Support

    That hook is added directly after the Content.

    You can use the same Hook to add your advertisement.

    #2597482
    Oppo Gene

    If we want to place ads within the content area, is it possible so?

    #2597517
    Oppo Gene

    also check this

    #2597551
    Fernando
    Customer Support

    Do you mean after these?: https://share.getcloudapp.com/Z4un1EOd

    #2597557
    Oppo Gene

    yes, but no after 2 files after some more no of files

    #2597576
    Fernando
    Customer Support

    Perhaps you can try reaching out to the plugin you used for these and ask if it’s possible to add a hook after every 2 files.

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