August 16, 200817 yr Hey all, I hope you are well. I'm busy with a site and I need to have 2 different types of comments forms. The usual comments on posts is pretty much sorted out. However, I want to call a different comment template for pages. Right now the default call from the template page is: <?php comments_template(); ?> That function calls to the comments.php file. However I want to call comments2.php which is my other comments page template. I have tried: <?php include('comments2.php'); ?> It does work but doesn't show the comments, just the comment form. I have a feeling a need to tweak some of the code in the actual comments2.php file. As I know pretty much next to nothing about this level of php, I don't know where to start. Here is the code that isn't display: <?php // Do not delete these lines if ('comments.php' == basename($_SERVER['SCRIPT_FILENAME'])) die ('Please do not load this page directly. Thanks!'); if (!empty($post->post_password)) { // if there's a password if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie ?> <p class="nocomments">This post is password protected. Enter the password to view comments.<p> <?php return; } } /* This variable is for alternating comment background */ $oddcomment = 'alt'; ?> <!-- You can start editing here. --> <?php if ($comments) : ?> <h3 id="comments"><?php comments_number('No comments', 'One Response', '% Responses' );?>, be sure to add yours.</h3> <ol class="commentlist"> <?php foreach ($comments as $comment) : ?> <li class="<?php echo $oddcomment; ?>" id="comment-<?php comment_ID() ?>"> <cite><?php comment_author_link() ?></cite> Says: <?php if ($comment->comment_approved == '0') : ?> <em>Your comment is awaiting moderation.</em> <?php endif; ?> <br /> <small class="commentmetadata"><a href="#comment-<?php comment_ID() ?>" title=""><?php comment_date('F jS, Y') ?> at <?php comment_time() ?></a> <?php edit_comment_link('e','',''); ?></small> <?php comment_text() ?> </li> <?php /* Changes every other comment to a different class */ if ('alt' == $oddcomment) $oddcomment = ''; else $oddcomment = 'alt'; ?> <?php endforeach; /* end for each comment */ ?> </ol> <?php else : // this is displayed if there are no comments so far ?> <?php if ('open' == $post->comment_status) : ?> <!-- If comments are open, but there are no comments. --> <?php else : // comments are closed ?> <!-- If comments are closed. --> <p class="nocomments">Comments are closed.</p> <?php endif; ?> <?php endif; ?> Any suggestions or even a fix would be appreciated. Thanks!
August 16, 200817 yr <?php if(is_page()) { include('comments-2.php'); } ?> Does that work? Have you tried using comments-2.php instead of comments.php for your posts? Does that work? Does the form on both comments pages have the same action?
August 16, 200817 yr Just had a thought. You could always try the is_single() / is_page() aspect in comments.php. How different are the two comments files?
August 16, 200817 yr Author Thanks Rachael, if give those a bash - was thinking of implementing the is_ tags. Will give feedback soon. The two files aren't too different, same function, just different copy basically.
August 18, 200817 yr Yea, the way I would do that is all within the comments.php file itself the way that rachael has mentioned
August 18, 200817 yr I'm surprised it's this fiddly to have two separate comment forms in WP - I thought it was the bees knees
August 18, 200817 yr Its very easy, you use comments-2 in the css if I recall, well thats what I do on mine also got one for admin.
Create an account or sign in to comment