- This topic has 13 replies, 3 voices, and was last updated 6 years, 2 months ago by Leo.
-
AuthorPosts
-
February 10, 2018 at 3:17 am #492794Dave 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
February 10, 2018 at 8:23 am #493002LeoStaffCustomer SupportHi 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.
February 12, 2018 at 6:19 am #494351Dave FoyDoh! Of course!
Thanks Leo. Much appreciated.
February 12, 2018 at 8:48 am #494508LeoStaffCustomer SupportNo problem π
February 12, 2018 at 1:40 pm #494742MikeHi 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
February 12, 2018 at 4:24 pm #494811LeoStaffCustomer SupportYou are close. Try the method for calling the shortcode here: https://generatepress.com/forums/topic/hooks-coding-for-placing-elementor/#post-409582
February 12, 2018 at 4:45 pm #494820MikeThanks 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
February 12, 2018 at 7:20 pm #494871LeoStaffCustomer SupportLike 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 }
February 13, 2018 at 9:00 am #495410MikeThanks, 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.
February 13, 2018 at 10:37 am #495490LeoStaffCustomer SupportEdited again.
February 13, 2018 at 10:39 am #495494MikeI’m sorry, I don’t know what “Edited again” means. Can you clarify, please?
February 13, 2018 at 10:43 am #495501LeoStaffCustomer SupportFebruary 13, 2018 at 10:45 am #495504MikeThanks! That worked. I really appreciate your help, Leo.
Have a good one!
February 13, 2018 at 10:48 am #495510LeoStaffCustomer SupportNo problem.
-
AuthorPosts
- You must be logged in to reply to this topic.