Jetpack

How to exclude a category from the Mobile Theme

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 your theme’s functions.php or 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.

Posted in Code snippets, Tips & Tricks | Tagged , , | Comments Off

How to add Javascript events to the Carousel view

Add this to your site’s js to enable events such as adding Google Analytics tracking code to individual Carousel slides:

jQuery(document).on( 'jp_carousel.selectSlide', '.jp-carousel-wrap', function( event, slides ) {
	// This is just to show you what values get passed in.  Delete it before going to production.
	if ( window.console ) {
		console.log( this );
		console.log( event );
		console.log( slides );
		console.log( slides[0] );
	}
	// Do whatever extra stuff you want here.
} );

You can read more about it here.

Posted in Code snippets, Tips & Tricks | Tagged , , | Comments Off

Tiles and Circles and Squares, Oh My!

Jetpack has lots of different modules that do all sorts of fun and interesting things to supercharge your self-hosted WordPress site. Not everyone uses all of these modules, though — with so much good stuff, it’s easy to miss something. To help you discover all the great things you could be doing with Jetpack, we’ll be highlighting the most-overlooked modules and the modules we get asked the most about. First up: Tiled Galleries!

Are you tired of plain old thumbnail galleries? Are row after row of tiny squares getting you down? Do you spend tons of time using photo editing software to create more interesting layouts for your images? Well have no fear, Tiled Galleries are here! Jetpack lets you display images in a variety of bold, elegant layouts with just a few clicks.

To insert a gallery into a post or page, the first thing you need, of course, are some images. Do you want to showcase your recent trip to New Mexico? Or maybe that new puppy you got? Any collection of images can be turned into a Tiled Gallery, whether you uploaded them to your site weeks ago or are just uploading them now.

Then, make sure that you’ve enabled the Tiled Galleries module in Jetpack. Activate it by going to the Jetpack page in your dashboard, and click the blue “Activate” button on the Tiled Galleries card.

Next, you’ll want to insert a new gallery into your page or post. To add a gallery, click on the “Add Media button,” and then on “Create Gallery” on the top left. You can then either upload new images or select images that are already in your media library. Choose the images you want, then click on the “Create a Gallery” button on the bottom right. Once you’ve created the Gallery, you can drag-and-drop the pictures to put them in the order you want them to appear in.

Now the fun part: choose the layout style that you want for your gallery, in the “Gallery Settings” area on the right, and let the Tiled Galleries module work its magic. You can have:

Square Tiles

or Circles

and my favorite, Tiled Mosaic

Great pictures, aren’t they? And they look smashing in the Tiled Galleries. Jetpack takes care of all the cropping and arrangement, and your site visitors can click any tile to pull up the full image.

I hope this inspires you to turn your regular Thumbnail Galleries into stylish Jetpack-powered Tiled Galleries!

Do you have any questions about Tiled Galleries? Is there a particular Jetpack module you’d like to learn more about? Let us know!

Posted in Features, Tips & Tricks | Tagged , , , | 23 Comments
Follow

Get every new post delivered to your Inbox.

Join 63,945 other followers