I’ve realised what the issue was… some of my posts were generated (for development purposes) using bulk creator which appears to not create a complete post! When I create a post manually using the WP backend my code works fine, thanks for the suggestions anyway guys!