guideplugin/result/template/module

Definition

With this filter you can customize the HTML code of each template module.

Parameters

appy_filters('guideplugin/result/template/module', $html, $module, $post_id, $guide_id);
  • $html (string) The HTML code of the module.
  • $module (array) The data of the module.
  • $post_id (int) The post ID.
  • $guide_id (int) The guide ID.

Example

The example shows you how to assign an external link of a WooCommerce product to the title module (advanced)

function my_guide_template_module_title($html, $module, $post_id, $guide_id)
{
    // Only modify title module on guide with ID 24
    if ($module['module'] == 'title' && $guide_id == 24 && function_exists('wc_get_product')) {

        $product = wc_get_product(get_the_ID());

        if ($product->is_type('external')) {
            ob_start();
            ?>
                <a href="<?php echo $product->get_product_url();?>" class="guide-result-template-title"><?php echo get_the_title(); ?></a>
            <?php 
            return ob_get_clean();
        }

    }

    return $html;
}
add_filter('guideplugin/result/template/module', 'my_guide_template_module_title', 10, 4);