Custom Layout – Hooks

This article is about the Hooks option in Custom Layout module of Astra Pro. Before proceeding further, make sure you go through the Custom Layout module overview first.

Custom Layout – Hooks option allows you to inject custom code or content in the various action hooks easily.

After selecting “Hooks” dropdown from Custom Layout, you get following options –

Action – 
Action is basically a location where your code or custom content will be injected. To see all actionsAstra offers and their locations, please visit this page.

Priority –
If there are multiple items added for a particular action, priority decides which item gets executed first. Lower the number, higher the priority.

Spacing –
If you need to add some padding above / below the custom content, use this option.

Adding Custom Code? You Got a Code Editor!

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 below:

You can use Page Builder as well.

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

Pro Tips:

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

Display Rules:

You can choose your custom layout to display on the entire website or on specific pages/posts with Display On option. You can even exclude particular page/post by adding them to Exclusion Rule.

Furthermore, we have provided user role option as well; so you can choose which users the code should execute for.

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

  • Display On: Entire Website
  • Add Exclusion Rule and set Do Not Display On: 404 Page
  • User Roles: Logged In

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