Actually add pagination param to media query.
Simplify handling of search variable -- it's not used outside function scope.