Clicky

  1. Home
  2. Developer Docs
  3. Hooks
  4. Hooks in AMP Theme Framework

Hooks in AMP Theme Framework

Let’s dig into one of the most important part of AMP theme framework and i.e., “Hooks”

We have added extra hooks in our AMP Theme Framework which will make the theme more playable.

Here is the complete list of all our hooks including their functionalities:

  1. Sitewide 
  2. single.php
  3. index.php

Sitewide { These hooks will run throughout the AMP website }


Actions Hooks

Description

amp_meta

It is used to add things in the head section of AMP which will come handy if you want to add some extra meta tags, to add extra js of AMP components and other things that will go in the head section.


amp_css

It is connected inside <style amp-custom> with the help of which you can add your own styling in AMP pages


amp_start

This hook is connected immediately after the beginning of the body tag. There are many use cases of it and some of them are GTM and analytics.


amp_end

You can use this one to add things before the end of the body tag, the most common usage is to add analytics. You can even add the social sticky with this hook.


 amp_after_header

It is useful if you want to add things right after the end of your header, like if you want to add view-non-amp or an ad immediately after the header then you can use this hook


amp_before_footer

It will be useful If you want to add things right after the article but before the footer.


amp_sidebar_start

This hook is connected right after the beginning of the amp-sidebar. If you want to add more things inside the sidebar and at the beginning of the sidebar, you can use this hook safely.


amp_sidebar_end

It’s the same as the above one but will be useful to add things before the end of the sidebar.


amp_post_template_head

It is used to add extra things in Head section of AMP which will come in handy if you want to add extra meta, JS of AMP components, etc..,


amp_post_template_css

It is used to add extra CSS to your AMP pages

single.php { Posts and Pages }


Actions Hooks

Description

ampforwp_before_post_content

This hook executes before the loop (single posts/pages). It can be used to add anything just above the loop.


ampforwp_after_post_content

This hook executes after the content.

index.php { These hooks will execute on HomePage}


Actions Hooks

Description

amp_before_loop

If you want to add few components or things or text above the loop of index, archive, and search then you can use this hook with ease


amp_after_loop

Do the same thing as the previous one, but is used to add components and any AMP related things after the end of the loop

We are going to add more hooks including components specific hooks in our future updates if you want you can also contribute to it.

That’s it for this tutorial!

We hope it helped you. If you have any feedback or questions, then please share them in the comments section below.

Ask your Questions Directly!
If you can't find the solutions in this article, then just ask us in the comments and we will answer it for you!
Updated on April 27, 2020

    Are you still looking for a solution?

    Then fill out the below form and we will reach out to you within a few hours.

    Was this article helpful?

    Related Articles

    Leave a Comment