Your code fails because of a PHP syntax error.
Things to note:
- Your problem is a result of your failure to indent your code correctly, resulting in things being missed. Your editor should be able to reindent code, and it should auto-indent as you type. There are no excuses for this, and it’s a 100% avoidable situation
- You do not have error logging turned on. Errors should be logged to an error log file, I strongly recommend you turn this on or find the file, and have it open 24/7 while developing
- I’d also suggest turning on the
WP_DEBUG
constant inwp-config.php
- Some editors ( any half decent editor ) can check syntax errors for you and highlight them
- a lot of editors don’t pick up the shorthand syntax of
while(): end;
, so always usewhile(){}
instead. It’s better to consistently use one or the other rather than both
To be precise it’s an extra }
causing your problem. Remove it and your code should work as expected assuming no other issues are present. I leave the task of syntax checking to you as homework. There are online checkers, PHP itself can check the syntax, and error logging will reveal it, both the line number and the cause.