I have a type of attachments that need full screen display. So, I need to put the comments form somewhere else. How can I tell WP those comments belongs to a post?
Leave a Reply
You must be logged in to post a comment.
I have a type of attachments that need full screen display. So, I need to put the comments form somewhere else. How can I tell WP those comments belongs to a post?
You must be logged in to post a comment.
Most starter themes now, like Twenty Eleven, come with separate files for each template â for example,
single.php
andcontent-single.php
represent the Single (Post) template in Twenty Eleven.The starter theme I use, Reddle (ddl), has the same template hierarchy, and here’s the solution I am using…
Create a blank Page (NOT Post) titled “Comments, Questions and Feedback” or something of your choice. Leave the body blank, and publish the page.
Make a copy of
single.php
and rename it topage-comments.php
(where “comments” in page-comments.php is the slug of the Page we created above).(A) In it, replace this:
with this:
(B) Also replace this:
with this:
Make a copy of
content-single.php
and rename it tocontent-comments.php
(in content-comments.php “comments” should be the same as the parameter you use in<?php get_template_part( 'content', 'comments' ); ?>
as shown above 2(B)).Now depending on what content you want to show on the standalone Comments page, edit out all the code in the template. For example, the first thing you might want to remove is the code that outputs the post’s content.
For example, this is the original
content-single.php
of my theme, and after editing out all the unnecessary code (that I didn’t want to show on the Comments page), this is what is left in the file:Add a rewrite rule to your .htaccess file to make the URL to the Comments page pretty:
Now, the Comments page for a post would be
http://example.com/comments/17/
if17
is its post ID.How will your readers know where to leave comments unless you link to the comments page? So, in your
content-single.php
or any template appropriate to you (depending on where you want to show the link), use this code:It’s really simple, and there’s no additional CSS involved as your comments pages inherit the same template as your posts. Yes, I did try this before sharing the answer here. It worked like a charm!
SCREENSHOTS
(Rough but working…)
Based on “Provide a Better Reading Experience in your WordPress Blog” by Amit Agarwal.
This is somewhat complex in that several things need to be done in order for it to work. I suggest you write this as a plugin instead of dumping it into your theme.
First thing you will need are the actual post comments, you have two options here:
get_comments
: http://codex.wordpress.org/Function_Reference/get_commentswp_list_comments
http://codex.wordpress.org/Function_Reference/wp_list_commentsBoth will need to be passed the post ID, I would suggest making a callback function for
wp_list_comments
.You will also need to use another function called
comment_form
to render the input for making actual comments. http://codex.wordpress.org/Function_Reference/comment_formInput and output of the comments is straightforward, the challenge is creating a relationship between the post and the separate comment form/display so that the user can easy navigate back and forth. I recommend reading MikeSchinkel’s answer in this post to accomplish that
Linking to Page Showing Only Comments Without Parent Post
What about a tabbed post page, just like reuters.com. You can use pure css or ajax and separate the post content from comments visually.