wp_is_mobile
wp_is_mobile
In many cases it is more than acceptable to hide/adjust/modify elements strictly by CSS for mobile screen widths. However there are cases when the limited bandwidth of mobile visitors demands that less than crucial elements on the page are eliminated from the page load.
“wp_is_mobile” allows you to set up a conditional statement that drops “heavy” items from the mobile experience
One way that this function could be used in a theme is to produce a very light version of the site that does not have the large payload of the desktop site. Note that both the desktop and the mobile versions of the page will still need to be responsive, as an older portrait phone will have a significantly different width than a modern iPad in landscape. wp_is_mobile() will be true for both. Similarly a desktop browser window may not be displayed at full width. Essentially this approach may double the amount of work you will need to put into the theme. Yet for a tightly optimized theme or a unique mobile experience, it may be essential. It also means that a proper theme may have at least three different responsive design specs: Desktop, Mobile and AMP.
https://developer.wordpress.org/reference/functions/wp_is_mobile/
<?php if ( wp_is_mobile() ) : ?>
/* Display and echo mobile specific stuff here */
<?php else : ?>
/* Display and echo desktop stuff here */
<?php endif; ?>