[Resolved] Can't find the 'generate_after_main_content' hook

Home Forums Support [Resolved] Can't find the 'generate_after_main_content' hook

Home Forums Support Can't find the 'generate_after_main_content' hook

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #492794
    Dave Foy

    Silly question time!

    I’m trying to locate the textarea for ‘generate_after_main_content’ in Appearance > GP Hooks. I can’t see it.

    Can you help me find it?

    I can see ‘generate_after_content’ (After Content) but not ‘generate_after_main_content’. Should there be a field called ‘After Main Content’?

    I have the ‘Show All’ dropdown set.

    Thanks very much. πŸ™‚

    Dave

    GeneratePress 2.0.2
    GP Premium 1.5.6
    #493002
    Leo
    Staff
    Customer Support

    Hi Dave,

    That hook is actually not in that list πŸ™‚
    The Show All options actually don’t show all the hooks GP has – it just shows the ones that are listed in that module.

    For generate_after_main_content, you will need to use this method: https://docs.generatepress.com/article/using-hooks/

    Here are all the hooks in GP: https://docs.generatepress.com/collection/hooks/

    Let me know if this helps.

    #494351
    Dave Foy

    Doh! Of course!

    Thanks Leo. Much appreciated.

    #494508
    Leo
    Staff
    Customer Support
    #494742
    Mike

    Hi Leo,

    I am Dave’s student. He kindly posted here to find an answer to this issue with which I’m having trouble. Namely, I want to be able to generate an Elementor template after the main content on the blog archive page.

    Dave directed me to this thread and, with his help, we have come up with the following code snippet as our attempt to make this work:

    add_action( ‘generate_after_main_content’,’mc_after_main_content_archive’ );
    function mc_after_main_content_archive() { ?>
    <?php if ( is_home() ) : ?>
    [elementor-template id=”369″]
    <?php endif; ?>
    <?php }

    Unfortunately, it didn’t work. Instead, only the text “[elementor-template id=”369″]” appears after the main content on the blog archive page. Can you advise as to how to be able to generate this template after the main content on the blog archive page?

    Thanks!

    Mike

    #494811
    Leo
    Staff
    Customer Support
    #494820
    Mike

    Thanks for your reply. However, I am not a coder and I have no experience with PHP. Can you give me an example of how I should write this snippet exactly?

    Thanks,

    Mike

    #494871
    Leo
    Staff
    Customer Support

    Like this:

    add_action( 'generate_after_main_content','mc_after_main_content_archive' );
    function mc_after_main_content_archive() { ?>
        <?php if ( is_home() ) : ?>
            <?php echo do_shortcode("[elementor-template id='####']"); ?>
        <?php endif; ?>
    <?php }
    #495410
    Mike

    Thanks, Leo. I copied/pasted your snippet into Code Snippet, with my Elementor template id (369) included.It looks like this:

    add_action( ‘generate_after_main_content’,’mc_after_main_content_archive’ );
    function mc_after_main_content_archive() { ?>
    <?php if ( is_home() ) : ?>
    echo do_shortcode(“[elementor-template id=’369′]”);
    <?php endif; ?>
    <?php }

    I saved/activated the snippet and checked the page.

    As a result, all that appears after the main content on the blog archive page is this line of text:

    echo do_shortcode(“[elementor-template id=’369′]”);

    Please help me add my Elementor template to the blog page after the main content. Thanks.

    #495490
    Leo
    Staff
    Customer Support
    #495494
    Mike

    I’m sorry, I don’t know what “Edited again” means. Can you clarify, please?

    #495501
    Leo
    Staff
    Customer Support
    #495504
    Mike

    Thanks! That worked. I really appreciate your help, Leo.

    Have a good one!

    #495510
    Leo
    Staff
    Customer Support
Viewing 14 posts - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.