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.

    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.

    This is a premium feature available with the Astra Pro Addon plugin. To use these pro features, you need to have the Astra theme along with the Astra Pro Addon installed on your website.

    Quick Steps to Add Hooks Using the Custom Layout Module
    Step 1: Make sure you have the Astra Pro Addon plugin installed and activated. How to Install Astra Pro Addon plugin?
    Step 2: Activate the module from the Astra Options under the WordPress Dashboard > Appearance > Astra Options
    Step 3: Visit customizer [ Appearance > Astra Options > Custom Layouts ] to edit module settings

    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 the following options –

    Action – 
    Action is basically a location where your code or custom content will be injected. To see all actions Astra 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:

    /* Add Your PHP Code here. */
    <script type="text/javascript">
    /* Add Your Java Script Code here. */
    <style type="text/css">
    /* Add Your CSS Code Here. */

    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. 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.

    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 a particular page/post by adding them to the 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 the following options –

    • Display On: Entire Website
    • Add Exclusion Rule and set Do Not Display On: 404 Page
    • User Roles: Logged Out
    Locate Display Hooks Settings

    Responsive Visibility

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

    Time Duration

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

    Layout will be visible for selected duration.

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

    Related Docs

    Scroll to Top

    Download is Just A Click Away!

    Be among the first to try the beta version of Astra’s Header Footer Builder. Filling the form will ensure you’ll be the first to learn about updates and features.

    Download is Just A Click Away!

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