How to fix pagination for custom loops?

The following is a basic construct of a custom query loop with properly functioning pagination functions: