Error when there are no posts
trsenna opened this issue · 3 comments
trsenna commented
Hi,
if possible, add the following code at https://github.com/tommcfarlin/page-template-example/blob/master/class-page-template-example.php#L164
// If no post found (404), return if ( !isset( $post ) ) return $template;
I'm using your solution in a plugin of mine and I got an error once I removed all posts and pages. What happens is that when we try to read the $post it returns an error 'cause there is no object there.
tommcfarlin commented
Nice catch! If you issue a pull request, I'm happy to merge it.
trsenna commented
Ok Tom, I added a TODO on my own project to not forget. Once I have some free time I will do the push request.
tommcfarlin commented
Sweet - thanks @trsenna!