Porto Hooks – Actions and Filters

Porto Hooks – Actions and Filters

WordPress provides Actions and Filters to allow developers to “hook into” specific parts of WordPress and modify or extend functionality without directly editing core files.

Similarly, the Porto Theme implements its own hooks, enabling you to modify theme-specific behavior through your child theme or a custom plugin.

How to Use a Hook or a Filter

Let’s say you want to display the product tab accordion on a specific product page. You can do this easily using a Porto filter.

  1. Copy and Edit Template
    Copy the single-product template file to your child theme and modify it as needed.
  2. Apply the Filter

    In your child theme’s single-product/tabs.php , add the following code

    add_filter( 'porto_single_product_data_tab_type', function() {
    return 'accordion';
    });

That’s it! The tab layout will now use the accordion style for that product.

Using Actions Instead of Filters

When customizing Porto via a child theme, use actions and filters whenever possible.
This approach makes your site easier to maintain and upgrade, since your changes are applied dynamically rather than by editing core files.

You can find many available Porto hooks and filters in the lists below.

Filters List

  1. porto/footer/footer_tooltip.php

    Description: Filters the footer tooltip content.

    apply_filters( 'porto_footer_tooltip', $tooltip_content );
  2. porto/header/header_tooltip.php

    Description: Filters the header tooltip content.

    apply_filters( 'porto_header_tooltip', $tooltip_content );
  3. porto/inc/admin/customizer/header-builder.php

    Description: Filters Customizer header builder elements.

    apply_filters( 'porto_header_elements', $elements );
  4. porto/inc/admin/setup_wizard/speed_optimize_wizard.php

    Filters all shortcodes:

    apply_filters( 'porto_all_shortcode_list', $shortcode_list );

    Filters all shortcodes currently used on the site:

    apply_filters( 'porto_used_shortcode_list', $used, $return_ids );
  5. porto/inc/functions/class-dynamic-style.php

    Filters internal dynamic CSS:

    apply_filters( 'porto_dynamic_style_internal_output', $this->minify_css( $css ) );
  6. porto/inc/functions/content_type.php

    Filters meta values, layouts, and sidebars:

    apply_filters( 'porto_get_meta_value_' . $meta_key, $value );
    apply_filters( 'porto_meta_layout', array( $value, $sidebar, $sidebar2 ) );
    apply_filters( 'porto_meta_default_layout', $value );
    apply_filters( 'porto_portfolio_sub_title', $output );
  7. porto/inc/functions/general.php

    Filters for template parts, screen sizes, and product detection:

    apply_filters( 'porto_get_template_part', $template, $slug, $name );
    apply_filters( 'porto_is_product', $result );
    apply_filters( 'porto_is_shop', $result );
  8. porto/inc/functions/layout.php

    Includes filters for header, footer, menus, wrappers, view switchers, minicarts, and more:

    apply_filters( 'porto_logo', ob_get_clean() );
    apply_filters( 'porto_get_wrapper_type', $porto_settings['wrapper'] );
    apply_filters( 'porto_is_dark_skin', $porto_settings['css-type'] === 'dark' );
  9. porto/inc/functions/layout/breadcrumbs.php
    apply_filters( 'porto_breadcrumbs', $output );
  10. porto/inc/functions/layout/page-title.php
    apply_filters( 'porto_page_title', $output );
    apply_filters( 'porto_page_sub_title', $output );
  11. porto/inc/functions/woocommerce.php

    Filters related to WooCommerce integration:

    apply_filters( 'porto_lazy_load_images', $thumb_image );
    apply_filters( 'porto_filter_cart_version', $cart_ver );
    apply_filters( 'porto_filter_checkout_version', $checkout_ver );

…and many more filters for infinite scroll, live search, pre-order dates, and shortcode rendering.

Actions List

  1. porto/content-archive-portfolio-fullscreen.php
    do_action( 'porto_portfolio_after_content' );
  2. porto/footer.php
    do_action( 'porto_after_main' );
    do_action( 'porto_after_wrapper' );
  3. porto/functions.php
    do_action( 'porto_enqueue_css' );
  4. porto/header/header_before.php

    Triggers before and after main wrappers and banners:

    do_action( 'porto_before_wrapper' );
    do_action( 'porto_before_header' );
    do_action( 'porto_after_banner' );

…and many more for sidebars, admin actions, builders, and templates.

JavaScript Hooks List

  1. porto/js/admin/admin.js

    Triggered when WooCommerce plugin initializes swatches:

    $wrapper.trigger('plugin_init');
  2. porto/js/theme-async.js

    Triggered when the login popup opens:

    $(window).trigger('porto_login_popup_opened');
  3. porto/js/theme.js

    Common frontend triggers for dynamic updates:

    $(document.body).trigger('porto_refresh_vc_content', [$elements]);
    $(document).trigger('porto_theme_init');
    $real.trigger('skeleton-loaded');

…and many more for sidebars, admin actions, builders, and templates.

Additional Pro Tips

  • Always use child themes for applying hooks or filters.
  • Never modify Porto’s core files.
  • Document your custom hooks for maintainability.
  • Use filters for modification, actions for extension.

Share:

Related Posts

Support Related Posts

Featured Posts

Porto is everything you need to create an awesome website!

Don’t have Porto Yet? Purchase Now!