I created the file
comments.php. Inside it I have a manual loop for my comments section. I loop from
offset = 0 + ((page - 1) * total_per to
offset + total_per). The problem is when I add new comments, the comment form's action field has the wrong URL generate. It consequently goes to the very last page of comments (ie. the oldest).
I had a question regarding this that I posted earlier. However after tracing some of the WP source code around I was able to find more information, so I deleted the original.
How can I ensure my theme's comment form generates the correct action URL without editing
Line 734 in
wp-includes/comment-template.php is causing the problem. I don't understand why though. I changed my theme to copy cpage, so I am no longer messing with any expected states. What I do know is that I can resolve my problem by hacking up the line in the core file. This change makes the generated URL go to the correct location.
if ( 'newest' === get_option( 'default_comments_page' ) )
if ( 'oldest' === get_option( 'default_comments_page' ) && 1 === $cpage )
It doesn't make sense to me that it disregards the cpage value for the URL, ONLY if the option is set to 'oldest'. I would think it should consider when to disregard cpage in either situation. It doesn't though, why is it hard coded to only consider when it
is Oldest at the top has the default page set to oldest, and cpage is at page 1? This makes no sense!
What am I doing to cause
get_comment_link() to generate the wrong page value? Is there a way for me to easily debug these things? I tried adding echos to the core code, but they didn't show up.
Here is all my comment form related source code. (I forgot to add the namespace for my functions "wbs", use the power of imagination because I can't edit the pastebin of it. comments.php(top) and functions.php(bottom) at http://pastebin.com/aer07uvF
Sorry I can only post 2 links with <10 rep.
comment_form() generates the correct URL, because the comment-page-1 should always have the oldest comments.