Site logo

Archived topic

No background video on Mobile

1 reply · Started by Brenden on May 13, 2022

Viewing posts 1–2 of 2

Hi Brenden,

You can give wp_is_mobile() a try, this is a WP function, for more info:
https://developer.wordpress.org/reference/functions/wp_is_mobile/

I would suggest duplicate the current page hero, so there will be 2 elements, 1 with video for desktop and 1 without video for mobile.

Then you can try this php snippet, replace 100 with the desktop element ID, replace 200with the mobile element ID.

add_filter( 'generate_element_display', function( $display, $element_id ) {
    if ( (100 === $element_id && wp_is_mobile()) || (200 === $element_id && !wp_is_mobile())  ) { 
        $display = false;
	}	
    return $display;
}, 10, 2 );
This archived topic is closed to new replies.