If you’ve ever wanted to exclude a particular category of posts from being displayed by Jetpack’s Mobile Theme, you can use the following code in a functionality plugin:
// Check if we are on mobile function jetpackme_is_mobile() { // Are Jetpack Mobile functions available? if ( ! function_exists( 'jetpack_is_mobile' ) ) return false; // Is Mobile theme showing? if ( isset( $_COOKIE['akm_mobile'] ) && $_COOKIE['akm_mobile'] == 'false' ) return false; return jetpack_is_mobile(); } // Modify the main query on the home page for the mobile theme. function jetpackme_modify_main_query( $arg ) { if ( jetpackme_is_mobile() && is_home() ) { $arg -> set( 'cat', '-1' ); } } add_action( 'pre_get_posts', 'jetpackme_modify_main_query' );
You would need to replace the 1 in
$arg -> set( 'cat', '-1' );
with the ID of the category you want to exclude.
Looking for more mobile tips? You’ll find them here! And if you more general need help with the Mobile Theme, take a look at our support doc.
This entry was posted in Code snippets, Tips & Tricks and tagged Minileven, Mobile, Mobile Theme. Bookmark the permalink.
Explore the benefits of Jetpack
Learn how Jetpack can help you protect, speed up, and grow your WordPress site.
Get up to 50% off your first year.
Compare plans