How to display content/content limit on desktops and excerpts on mobiles in Genesis
This tutorial provides the steps to use Mobble plugin to display content or content limit (depending on what's set in the Genesis theme settings) for desktops & tablets and excerpts on mobiles.
Step 1
Install and activate Mobble.
[optional] The plugin has not been updated in 2 years time and includes an old version of Mobile-Detect PHP library. You may want to manually replace the included Mobile_Detect.php
file with the latest one. You will, of course, lose this when the plugin gets an update which should not be an issue because the update will most likely include the latest Mobile_Detect.php anyway.
Step 2
The entry content in Genesis comes from genesis_do_post_content()
defined in genesis/lib/structure/post.php.
Let's remove this function from the genesis_entry_content
hook and hook a customized one that checks for mobiles and shows excerpts (on mobiles only) regardless of the content archives theme settings.
Add the following in child theme's functions.php:
To view the full content, please sign up for the membership.
Already a member? Log in below or here.
Great tut! But I’m always struggling when it comes to caching. When using this method, we need to separate cashed mobile and desktop versions. So that when I visit the page now using my smartphone, and a moment later with my desktop, I will be served the mobile version. Maybe you could go in depth about how to properly seperate browser cache when using caching plugins? Hope this is on topic, because I realise this isn’t genesis specific, though it could be an extension of this tut.
Cheers,
Niels