{"id":2982,"date":"2010-01-16T18:00:32","date_gmt":"2010-01-16T16:00:32","guid":{"rendered":"http:\/\/blog.ginchen.de\/?p=2982"},"modified":"2012-01-25T15:20:36","modified_gmt":"2012-01-25T14:20:36","slug":"leere-seite-nach-dem-kommentieren-eines-wordpress-posts","status":"publish","type":"post","link":"http:\/\/blog.ginchen.de\/en\/2010\/01\/16\/leere-seite-nach-dem-kommentieren-eines-wordpress-posts\/","title":{"rendered":"Blank page after commenting on a WordPress post"},"content":{"rendered":"<p>This issue is certainly known to a few, and I too have had the problem for a while that I couldn&#8217;t leave any comments on my own blog when logged in as admin (I could comment only from the back end, but not from the website). Today I have finally taken the &#8220;time&#8221; to go to the root of the problem. I am writing this in quotes, because in the end it didn&#8217;t take me three minutes to find the error. If only I had started searching much earlier. ;)<\/p>\r\n\r\n\r\n<!--more-->\r\n\r\n\r\n\r\n\r\n<p>The problem was a missing hidden input in the comment form, which is required by WordPress:<\/p>\r\n\r\n<pre lang=\"html4strict\"><input type=\"hidden\" name=\"comment_post_ID\" value=\"<?php echo $post->ID; ?>\" \/><\/pre>\r\n\r\n<p>So if you constantly get a blank page after submitting a comment, you should check your comments template (usually that&#8217;s the file <code>comments.php<\/code> in the directory of your theme) to see if this line has been forgotten or inserted at a wrong place.<\/p>\r\n\r\n<p>In my case, for example, I had inserted the line in the wrong place inside an if statement:<\/p>\r\n\r\n<pre lang=\"html4strict\">\r\n<?php if ( $user_ID ) : ?>\r\n\t<p>You are logged in as ...<\/p>\r\n<?php else : ?>\r\n\t[Form fields for name, email etc.]\r\n\t<input type=\"hidden\" name=\"comment_post_ID\" value=\"<?php echo $post->ID; ?>\" \/>\r\n<?php endif; ?>\r\n<\/pre>\r\n\r\n<p>Thus the line was present for not logged-in visitors (guests), so they could comment without any problems. However, if you were logged in (which I, as the admin, of course always was), the line was missing, and if it&#8217;s missing, WordPress exits its comment script with a blank page <em>without comment<\/em> (haha!).<br \/>\r\nCorrectly, it has to be like this of course:<\/p>\r\n\r\n<pre lang=\"html4strict\">\r\n<?php if ( $user_ID ) : ?>\r\n\t<p>You are logged in as ...<\/p>\r\n<?php else : ?>\r\n\t[Form fields for name, email etc.]\r\n<?php endif; ?>\r\n<input type=\"hidden\" name=\"comment_post_ID\" value=\"<?php echo $post->ID; ?>\" \/>\r\n<\/pre>\r\n\r\n<p>This way, the line is displayed in all cases, and then it also works as an admin!<\/p>","protected":false},"excerpt":{"rendered":"This issue is certainly known to a few, and I too have had the problem for a while that I couldn&#8217;t leave any comments on my own blog when logged in as admin (I could comment only from the back end, but not from the website). Today I have finally taken the &#8220;time&#8221; to go [&hellip;]","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[77],"tags":[161,426,606,163],"_links":{"self":[{"href":"http:\/\/blog.ginchen.de\/en\/wp-json\/wp\/v2\/posts\/2982"}],"collection":[{"href":"http:\/\/blog.ginchen.de\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.ginchen.de\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.ginchen.de\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.ginchen.de\/en\/wp-json\/wp\/v2\/comments?post=2982"}],"version-history":[{"count":5,"href":"http:\/\/blog.ginchen.de\/en\/wp-json\/wp\/v2\/posts\/2982\/revisions"}],"predecessor-version":[{"id":5789,"href":"http:\/\/blog.ginchen.de\/en\/wp-json\/wp\/v2\/posts\/2982\/revisions\/5789"}],"wp:attachment":[{"href":"http:\/\/blog.ginchen.de\/en\/wp-json\/wp\/v2\/media?parent=2982"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.ginchen.de\/en\/wp-json\/wp\/v2\/categories?post=2982"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.ginchen.de\/en\/wp-json\/wp\/v2\/tags?post=2982"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}