How to Use Hooks in Custom Layout Module of Astra Pro?

No results found. Try again with different words?

Search must be at least 3 characters.

Site Builder – Hooks

Whether you want to add a custom header, footer, or any section with specific content, Hooks provides the flexibility to add your creativity to your website.

With Site Builder, a module available with Astra Pro, you can insert custom code or content using Astra hooks. This article will show you how to set up the Hooks Site Builder.

In addition, Site Builder require both the Astra theme and Astra Pro Addon installed and activated on your website. Further, before proceeding, you can check out the Site Builder module overview first.

How to Add Hooks Layout

You can follow the below steps to add hooks Site Builder.

  • In the dashboard, click on Astra and scroll down to Astra Pro Modules, and activate the Site Builder module;
  • Next, navigate to Astra > Site Builder and click on the “Add New” button;
  • Here, you will see the Site Builder Type selection pop-up. Here, select the “Hooks” option.
  • Next, you can add a custom code. To do this, you can click the “Enable Code Editor” button. This option enables the code editor which is helpful to add custom code.

While adding your code, please make sure to include opening statements of the code which pasting your code. Some examples are below:

<?php
/* Add Your PHP Code here. */
?>
<style type="text/css">
/* Add Your CSS Code Here. */
</style>

How to Add Hooks using Page Builder

You can create a layout with page builder too, and add it to any action hook. For example, you can design a call to action with a page builder; or a newsletter subscription form and display it automatically below the content of all blog posts.

Pro Tips:

  1. For Beaver Builder: Make sure your page builder is enabled for the “Custom Layouts” post type. For example, Beaver Builder has a setting for that.
  2. For Elementor: Make sure your page builder is enabled for the “Custom Layouts” post type.
  3. If you’re having trouble loading the page builder for any Custom Post Type such as this, please flush your permalink settings and try again.

What are the Hooks Layout Options

If you click on the Astra icon in the top right corner, you will open the Site Builder Setting panel. Further down, you will find the overview of the Hooks layout type options.

After selecting the “Hooks” dropdown from Site Builder, you get the following options:

  • Placement: From the dropdown, choose the custom hook option and enter the custom hook name.
  • Priority: If there are multiple items added for a particular action, priority decides which item gets executed first. The lower the number, the higher the priority.
  • Spacing: If you need to add some padding above/below the custom content, use this option.

Display And User Role Settings

Next, you can set the exact pages/posts where you want your hooks layout to be used. Thus, you need to adjust Display and User Rule Settings.

You can choose your Site Builder to display on the entire website or on specific pages/posts with the Display On option. In addition, you can exclude some locations using the “Do Not Display On” option.

Furthermore, you can disable your added hooks layout only for some user roles. You can do this with the User Roles option.

For example:
If you want to inject a call to action on the Entire Website; Except on 404 page; For Logged Out users, you need to set the following options –

  • Display On: Entire Website
  • Do Not Display On: 404 Page
  • User Roles: Logged Out

Hooks Device Visibility

This option lets you choose a device where you wish to display the Site Builder. Just tick the checkbox for required devices – Desktop, Tablet, and Mobile.

Date & Time Conditions

You can set a start time and end time for layout visibility. Set a date and time duration for the layout.

The layout will be active for the selected duration.

Thus, the custom hooks layout allows you to maintain a uniform look and feel across your Site Builder while still allowing flexibility for content customization.

We hope this article has been helpful. If you have any questions, please feel free to leave a comment below.

Was this article helpful?
Did not find a solution? We are here to help you succeed.

Related Docs

Astra is Free. Now & Forever.

We believe creating beautiful websites should not be expensive. That's why Astra is free for everyone. Get started for free and extend with affordable packages.

REWIND

YEAR IN REVIEW

Download is Just A Click Away!

Enter your email address and be the first to learn about updates and new features.

Download Free Astra Theme - Modal Popup Form
Scroll to Top
Now choose your preferred
page builder addon
Choose your preferred page builder addon

Download is Just A Click Away!

Enter your email address and be the first to learn about updates and new features.

Download Free Astra Theme - Modal Popup Form