I'm not a fan of this solution, but you could simply add an element with the number of posts you want to show on mobile that is hidden by default and only shown when the media-query condition is met.
Imagine the following html containing your mobile posts
<div class="is-mobile">
<div class="im-a-post">some content</div>
<div class="im-a-post">some content</div>
<div class="im-a-post">some content</div>
<div class="im-a-post">some content</div>
<div class="im-a-post">some content</div>
</div>
<div class="is-default>
<div class="im-a-post">some content</div>
<div class="im-a-post">some content</div>
<div class="im-a-post">some content</div>
<div class="im-a-post">some content</div>
<div class="im-a-post">some content</div>
<div class="im-a-post">some content</div>
<div class="im-a-post">some content</div>
<div class="im-a-post">some content</div>
<div class="im-a-post">some content</div>
<div class="im-a-post">some content</div>
</div>
The via a simple media query you toggle the visibiliy of your wrapper elements:
.is-mobile {
display: none;
}
@media (max-width: 480px) {
.is-default {
display: none;
}
.is-mobile {
display: block;
}
}
A more sophisticated (and imho better) approach would be to either annotate the elements you would want to hide (by adding a class) via javascript/php or even CSS3 :nth-child()
selectors. Imagine the following javascript loop
// assuming jQuery
$(".posts").each(function(idx, ele) {
if (idx >= 5) {
$(ele).addClass("hidden-mobile");
}
});
with this CSS
@media (max-width: 480px) {
.hidden-mobile {
display: none;
}
}
Together those would hide all but the first five posts on a device where the viewport matches. But then you would have to take pagination properly into account.