How to Effectively Customize Jetpack Related Posts for Mobile – All Screen Sizes Inclusive

How to Effectively Customize Jetpack Related Posts for Mobile And Desktop
Optimize Jetpack Related Posts for All Devices

“Related posts” is a feature deployed by CMSs (Content Management Systems) to display related posts below contents in websites/blogs. The related posts feature normally uses posts contents, categories and tags to automatically show contents related to the current post the user is viewing.

In this post, you will learn how to optimize Jetpack related posts to display perfectly well across all devices.

Jetpack Related Posts is one of great features that comes with Jetpack WordPress plugin which can be used to display related posts on WordPress website.

Jetpack is a powerful toolkit made by WordPress experts which can help WordPress site to get a safer and stronger, Load pages faster and Increase traffic through some tools like social sharing, related posts/content and site search.

How to Enable Jetpack Related Posts

If you don’t have Jetpack installed on your WordPress site, check out our post on how to properly install Jetpack.

Follow these steps to properly activate and setup related posts by Jetpack on your WordPress site.

  1. Click “Jetpack” at the left menu on WordPress admin dashboard.
  2. Click on “Settings”.
  3. Click on “Traffic” on the tabs.
  4. On the “Related posts” section, toggle on “show related content after posts”
  5. You can optionally toggle on “Highlight related content with a heading” (Which by default is set to “Related”) and “Show thumbnail image where available”.
  6. Click on “Save settings”.
  7. Once you have saved the settings, click on “Configure related posts in the Customizer”.
  8. At the customizer, set the layout to grid.
How to Enable Jetpack Related Posts
Jetpack Related Posts Setup Screen

Related posts will now be displayed at the end of each post on your website.

Note: At the customizer, the most important thing to set is the “Layout”, because it will be later customized to be friendly on all screen sizes in this post. You can as set other options to your taste.

Jetpack Related Posts Settings in the customizer
Screenshot of Jetpack related posts configurations in Customizer

That’s all about enabling related posts, it is now time to time to customize jetpack posts for responsiveness on all device screen sizes.

General Information About jetpack related posts

  • Related posts will only appear below post content if 3 good results can be shown. So, don’t be surprised if some posts do not show related contents.
  • Related content is automatically generated based on the content of the post and any tags or categories if they exist.
  • Minimum number of related posts to show is 3 and the maximum is 6.

Also read 👇

Simple Trick to Fix “Your IP Address Has Changed” Error Message On cPanel

How to Optimize Jetpack Related Posts for Mobile and Desktop View

If you have successfully activated related posts by Jetpack, look out for the configurations below to increase the number of related posts shown below contents and also make the related responsive on all screen sizes.

Note: We strongly recommend not make customizations on you parent theme, because when your theme updates you may lose every customization you have made.

Create a child theme from your parent theme and add your code to it.

1. Increase the number of related posts shown below contents

You might not be okay with number of posts shown as related contents by default (3 posts) and want to change it.

Add this code below to your child theme’s “functions.php” file.

//Change number of jetpack related posts

function jetpackinc_more_related_posts( $options ) {
 $options['size'] = 4;
 return $options;
}
add_filter( 'jetpack_relatedposts_filter_options', 'jetpackinc_more_related_posts' );

Note: change 4 in the code above to the number of posts you desire to display (remember that max is 6 while minimum is 3).

2. Style jetpack related posts with CSS (cascading Style Sheets)

When you must have increased your related posts to say 4 or 6, you will notice that the display on mobile is not all that good. While it may look or may not look perfect to you on desktop view. This is because jetpack related posts are kind of designed to display contents in three contents per group. Once a row or group is up to 3 contents, the next content(s) seems to jump to a new row.

Paste this CSS as code in your child theme’s “style.css” to fix the issue above.

/*
Jetpack related posts formatting 
*/
@media only screen and (max-width:1920px)
{#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post:nth-child(2n+3), #jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post:nth-child(2n+3) {
    clear: both !important;
}
#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post:nth-child(3n+4), #jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post:nth-child(3n+4) {

    clear: none !important;
}
#jp-relatedposts .jp-relatedposts-items .jp-relatedposts-post:nth-child(3n+4), #jp-relatedposts .jp-relatedposts-items-visual .jp-relatedposts-post:nth-child(5n+6) {

    clear: none !important;
}
}

When you successfully add the above code, your Jetpack related posts will display just as in the screenshots below across all device, undoubtedly that looks way nicer and at the same responsive. You may need to clear your browser cache before the changes you made stare at you.

How Jetpack related posts will look after customization
How Jetpack related posts will look after customization – Desktop
Mobile view of Jetpack Related Posts After Customization
Mobile view of Jetpack Related Posts After Customization

Wrapping Up

There are lots of benefits to gain from adding related contents to your website. Hope the posts helped you to effectively add extra customizations to jetpack related. If you have any difficulties achieving this, relate it to us via the comment box. Thanks for having you here.