Avada Hooks: Actions and Filters

07/21/2017

Actions and Filters are provided by WordPress to allow your plugin to ‘hook into’ the rest of WordPress; the same concept is used by Avada to allow hooking into Avada specific functionality so that you can modify it in a child theme or even a plugin.

How To Use a Hook Or A Filter?

So, let’s assume you want to add a banner ad before the entire header. There are three ways to do that:

1. Edit the parent theme’s code and add the code in the header file
2. Copy the header file into the child theme and modify the code in that file
3. Use an action in a child theme’s functions.php

With the #1 and #2 above, there is a high possibility that the edit would be lost during an update. By using an action, you don’t edit or overwrite the core code which is why, your code will rarely need to be changed.

To add a banner ad before the entire header, we need to use the avada_before_header_wrapper action in the functions.php of the child theme. Following is an example code:

Filters are similar to the actions but instead of ‘hooking’ into the code, you are simply changing the final output. You can read more about the difference difference between actions and filters from the beginner’s guide.

How To Add Code After The Opening Body Tag

To add code, such as GTM script, after the opening <body> tag, you will have to use the avada_before_body_content filter. If you’re not familiar with editing child theme files or you don’t have a child theme installed, you can install the Code Snippets plugin then add this code in it:

Conversion For Child Themes

If you’d like to learn how to convert Child Themes and your own Custom Post Types, please click the button below and follow the instructions in the article.

Click Here To Read About Converting Child Themes and Custom Post Types

Actions List

ACTIONS
FILE NAME
DESCRIPTION
avada_before_header_wrapper Avada/includes/avada-functions.php
Avada/templates/side-header.php
This hook is executed before the div that wraps the entire header (includes main header and top header).
ARGUMENTS: None
avada_header Avada/includes/avada-functions.php By default, this hook outputs the header, including top header and the main header.
ARGUMENTS: None
avada_after_header_wrapper Avada/includes/avada-functions.php
Avada/templates/side-header.php
This hook is executed after the div that wraps the entire header (includes main header and top header).
ARGUMENTS: None
avada_before_body_content Avada/header.php This hook is executed right after the <body> tag.
ARGUMENTS: None
avada_header_inner_before Avada/templates/side-header.php This hook is executed only when side header is used and before any kind of content including logo.
ARGUMENTS: None
avada_header_inner_after Avada/templates/side-header.php This hook is executed only when side header is used and after all content. An example usage would be to insert a widget area in the side header after all the content.
ARGUMENTS: None
avada_logo_prepend Avada/templates/logo.php This hook is executed directly before the logo html.
ARGUMENTS: None
avada_logo_append Avada/templates/logo.php This hook is executed directly after the logo html.
ARGUMENTS: None
avada_override_current_page_title_bar Avada/header.php This hook will override the existing page title bar.
ARGUMENTS: $c_pageID
avada_before_main_container Avada/header.php This hook is executed before the div id #main. An example usage would be to add AdSense before the content area.
ARGUMENTS: None
avada_author_info Avada/author.php This hook is executed on the author info page to add author info.
ARGUMENTS: None
avada_after_content
fusion-core/templates/archive-avada_portfolio.php
fusion-core/templates/single-avada_portfolio.php
Avada/archive-wpfc_sermon.php
Avada/archive.php
Avada/author.php
Avada/bbpress.php
Avada/buddypress.php
Avada/contact.php
Avada/page.php
Avada/search.php
Avada/side-navigation.php
Avada/index.php
Avada/single-wpfc_sermon.php
Avada/single.php
Avada/taxonomy-wpfc_bible_book.php
Avada/taxonomy-wpfc_preacher.php
Avada/taxonomy-wpfc_sermon_series.php
Avada/taxonomy-wpfc_sermon_topics.php
Avada/includes/class-avada-layout.php
Avada/includes/woo-config.php
Avada/includes/class-avada-woocommerce.php
Avada/sensei/wrappers/wrapper-end.php
Avada/tribe-events/default-template.php
This hook is executed after the #content div primarily to add sidebars.
ARGUMENTS: None
avada_footer_copyright_content Avada/footer.php This hook is executed to add copyright content in the copyright content area.
ARGUMENTS: None
fusion_options_save Avada/includes/lib/inc/class-fusion-fusionredux.php This hook is executed after saving theme options.
ARGUMENTS:
$data
$changed_values
avada_rollover Avada/includes/lib/inc/templates/featured-image-first.php This hook is executed to add rollovers over images.
ARGUMENTS:
$post_id
$post_permalink
$display_woo_price
$display_woo_buttons
$display_post_categories
$display_post_title
$gallery_id
$display_woo_rating
avada_blog_post_date_and_format Avada/templates/blog-layout.php This hook is executed to add blog and post format boxes to medium alternate layout.
ARGUMENTS: None
avada_after_main_content Avada/footer.php This hook is executed to display custom Content right after #Content and .sidebar Containers, but still inside #main container.
ARGUMENTS: None
avada_after_main_container Avada/footer.php This hook is executed to display custom Content just before the footer, outside of #main container.
ARGUMENTS: None
avada_before_comments Avada/comments.php This hook is executed to display custom Content just after the page contents, but before the comment section is displayed.
ARGUMENTS: None
avada_blog_post_content Avada/templates/blog-layout.php This hook renders the actual post content. Custom content can be displayed before or after the post content.
ARGUMENTS: None
avada_portfolio_post_content
fusion-core/templates/portfolio-archive-layout.php
This hook renders the actual portfolio content. Custom additions can be displayed before or after it by setting the corresponding hook priority.
ARGUMENTS:
$archive_id
$current_page_id
avada_placeholder_image
Avada/includes/lib/inc/templates/featured-image-first.php
fusion-builder/inc/lib/inc/templates/featured-image-first.php
This hook is used to create a placeholder markup. Different markup can be used, when removing the theme action and adding a custom one.
ARGUMENTS: $post_featured_image_size
avada_woocommerce_buttons_on_rollover Avada/includes/lib/inc/templates/rollover.php This hook is used to add the WooCommerce add to cart buttons to the featured image rollover.
ARGUMENTS: None

Filters List

FILTERS
FILE NAME
DESCRIPTION
fusion_faq_all_filter_name fusion-core/shortcodes/fusion-faq.php Applied to the “All” text on the portfolio filters.
DEFAULT VALUE: __( ‘All’, ‘Avada’ )
fusion_blog_read_more_excerpt Avada/includes/avada-functions.php Applied to the blog Read More title text.
DEFAULT VALUE: […]
avada_viewport_meta Avada/includes/class-avada-head.php Applied to the viewport meta.
DEFAULT VALUE: none
avada_set_placeholder_image_height Avada/includes/avada-functions.php Applied to the placeholder image height.
DEFAULT VALUE: 150
avada_breadcrumbs_defaults Avada/includes/class-avada-breadcrumbs.php Applied to the default values of breadcrumb.
DEFAULT VALUE:
array(
‘home_prefix’ => $this->options[‘breacrumb_prefix’],
‘separator’ => $this->options[‘breadcrumb_separator’],
‘show_post_type_archive’ => $this->options[‘breadcrumb_show_post_type_archive’],
‘show_terms’ => $this->options[‘breadcrumb_show_categories’],
‘home_label’ => __( ‘Home’, ‘Avada’ ),
‘tag_archive_prefix’ => __( ‘Tag:’, ‘Avada’ ),
‘search_prefix’ => __( ‘Search:’, ‘Avada’ ),
‘error_prefix’ => __( ‘404 – Page not Found’, ‘Avada’ ),
);
avada_ipad_portrait_styles Avada/includes/dynamic_css.php Applied to the css styles for iPad Portrait.
DEFAULT VALUE: $ipad_portrait
avada_dynamic_css_array Avada/includes/dynamic_css.php Applied to the dynamic CSS array.
DEFAULT VALUE: $css
avada_dynamic_css Avada/includes/class-avada-dynamic-css.php Applied to the final compiled CSS from dynamic CSS.
DEFAULT VALUE: $css
avada_load_more_posts_name Avada/templates/blog-layout.php Applied to the text for the load more button.
DEFAULT VALUE: __( ‘Load More Posts’, ‘Avada’ )
avada_header_separator Avada/includes/avada-functions.php Separator for top header content, not menu.
DEFAULT VALUE: |
avada_header_contact_info_email Avada/includes/avada-functions.php Applied to the email address in top header.
DEFAULT VALUE: %s
fusion_sharing_box_tagline Avada/templates/social-sharing.php Sets a custom sharing box tagline. This will override the setting in Theme Options.
DEFAULT VALUE: “Share This Story!” (can be set in Theme Options)
27 Likes
Proudly Serving Over 375000 Satisfied Users!