You need to create a page from wp-admin->Pages
and assign your template as the “Template”. Until you do that, WordPress won’t know where to find the “page”– won’t know what to do with the request– and you will get a 404. I think that is about it, really.
Think about where your file is actually located on the server– http://sitename.com/wp-contents/themes/themename/comments-side.php
— but you are trying to access it at http://myurl.com/post-slug/comments-side/
, exactly where it isn’t. WordPress and the server conspire to lie about file locations, so for this to work WordPress has to be told about the page. The rewrite mechanisms won’t work otherwise.
The bare minimum for getting your comments to work is to pass the post ID via a get parameter like this– http://sitename.com/wp-contents/themes/themename/comments-side.php?sac=123
— and fetch comments like this:
if (isset($_GET['sac'])) {
$comments = get_comments(array('post_id'=>$_GET['sac']));
wp_list_comments('',$comments);
}
I can’t get function like have_comments
to work though I’ve not tried before now. There may be a way to do it. So, until further notice remove the have_comments
check. That will fail.
There is no data validation in that code. I’m just testing things. Don’t push the GET
string through without validation.