This is a premium feature available with the Astra Pro Addon plugin. The Astra theme and Astra Pro Addon are installed and activated 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.
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 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.
If there are multiple items added for a particular action, priority decides which item gets executed first. Lower the number, higher the priority.
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:
<?php /* Add Your PHP Code here. */ ?>
<style type="text/css"> /* Add Your CSS Code Here. */ </style>
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.
- For Elementor: Make sure your page builder is enabled for the “Custom Layouts” post type.
- 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.
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.
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
Not the solution you are looking for? Check our other articles.