Disable loading=”lazy” on images in first block

add_filter(
	'pre_render_block',
	function( $pre_render ) {
		global $cwp_block;
		if ( empty( $cwp_block ) ) {
			$cwp_block = 1;
		} else {
			$cwp_block++;
		}
		return $pre_render;
	}
);

add_filter(
	'wp_lazy_loading_enabled',
	function( $default ) {
		global $cwp_block;
		if ( 1 === $cwp_block ) {
			$default = false;
		}
		return $default;
	}
);
Bill Erickson

Bill Erickson is the co-founder and lead developer at CultivateWP, a WordPress agency focusing on high performance sites for web publishers.

About Me
Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk