Using Hooks in Astra

Description

Hooks allow you to add extra functionality at a various areas inside the theme. For example, you might want to some promotional message below all of your blog posts. Hooks make such dynamic things possible.

Astra uses WordPress Hooks API to insert various hooks throughout the theme.

Usage

In the example above, replace hook_name with the name of the hook you’re wanting to use, like astra_header_before or astra_header_after. Then replace callback_function_name with a unique meaningful function name, something specific to you.

To see the list of hooks available in Astra Visually, checkout this site we’ve set.

Example

The astra_header_before hook is executed right before the Site Header.

Note: Site Header – <header id=”masthead”>.

Add PHP to your header

or…

Add HTML to your header

If you are adding PHP to astra_header_before(), use the first method. Use the second method for anything else you may be adding.

Not the solution you are looking for? Check other articles, or open a support ticket.