Your posts are in ul list. you need to count the length of the li‘s under this ul#postlist [assuming that each li is a post]
<ul data-filter="true" data-filter-placeholder="Search blog posts..." id="postlist"> </ul><!-- content -->
Change your $('#postlist')
var currentPost = $('#postlist');
with
var currentPost = $('#postlist li');
$('#postlist li') is what you are looking for,
solved Count the number of current posts in Div