Site logo

Archived topic

Can't find the 'generate_after_main_content' hook

13 replies · Started by Dave Foy on February 10, 2018

Viewing posts 1–14 of 14

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

Doh! Of course!

Thanks Leo. Much appreciated.

No problem :)

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

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

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 }

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.

Edited again.

I'm sorry, I don't know what "Edited again" means. Can you clarify, please?

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

Have a good one!

No problem.

This archived topic is closed to new replies.