Home / Admin / Elementor Store Headers
Duplicate Snippet

Embed Snippet on Your Site

Elementor Store Headers

Gives support for Elementor on WC Vendor Headers

Code Preview
php
<?php
// Add the woocommerce_before_main_content to the elementor wc-archive-products widget 
add_action( 'elementor/widget/render_content', function( $content, $widget ) {
	if ( 'wc-archive-products' === $widget->get_name() ) {
		 // Run the hooks without outputting the code that `do_action` will want to do
		 ob_start();
		 do_action('woocommerce_before_main_content');
		 $beforeMainContent = ob_get_contents();
		 ob_clean();
		 do_action('woocommerce_after_main_content');
		 $afterMainContent = ob_get_contents();
		 ob_end_clean();
		 // Attach the output from the two hooks before and after the content generated by Elementor
		$content = $beforeMainContent . $content . $afterMainContent;
	}
 
	return $content;
 }, 10, 2 );

Comments

Add a Comment