The Problem is that you query for Post Status null. Try setting this to publish or inherit, because get_permalink is a function for published items, not for any post status.

This is because Permalinks to items with a status like draft should not be shown to the user.

get_permalink to attachment not working
I suspect that one or more of my servers is compromised by a hacker, virus, or other mechanism:


What are my first steps? When I arrive on site should I disconnect the server, preserve "evidence", are there other initial considerations?
How do I go about getting services back online?
How do I prevent the same thing from happening immediately again?
Are there best practices or methodologies for learning from this incident?
If I wanted to put a Incident Response Plan together, where would I start? Should this be part of my Disaster Recovery or Business Continuity Planning?


 This is meant to be a canonical post for this topic. Originally from serverfault. 
