INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Comments form on a page, not post

Comments form on a page, not post

(OP)
Hi,

How easy is it to put a comments form on a PAGE as opposed to a post? I've used an include comment.php command into one of my pages and it displays the form ok. I can submit a comment ok and it registers the comment in my dashboard ok. I've set my comments for no approval so the page should then instantly display the first comment, but it doesn't. It just displays the form as if it hadn't received a comment.

Is this because:

a) I'm using an include instead of echoing <? php comments_template() ; ? >?
b) Putting a comments form on a page is confusing the script, which is looking for a reference to a post id?

What is the work-around (short of using Cformsii to create a new form...I'm unsure how to use this plug-in).

Any help appreciated!

RE: Comments form on a page, not post

Hi there,

in reverse order ...

2/ no. this won't confuse it.  a page is just a post with a different taxonomy.  in fact just about everything in WP goes into the 'posts' bucket and is differentiated by a taxonomy code.

1/ quite probably, yes.  the file wp-includes/comments_template.php does all the heavy lifting of actually getting the comments themselves from the database and bringing them into scope for the template to output.  the comments template typically uses have_comments() to check whether comments exist.  this is defined in query.php.  the relevant function (as of 2.7) simply checks the existence of cached comments in the $wp-query object.  so if you have not previously run the comments_template() function you are unlikely to have populated the necessary variables in $wp-query.
 
to cut a long story short, uses <?php comments_template(); ?> !!

RE: Comments form on a page, not post

(OP)
Hi,

thanks for your reply and thank you for clearing that up for me.

Since my question was posted I am now using a conditional statement to show the comment form only on a certain page. So

CODE

<?php if (is_page('32')); ?>
<div class="comments"><?php comments_template(); ?></div>
<?php endwhile; endif; ?>

I've put this in the loop which is why there is the endwhile as well as the endif at the end of this statement.

The problem, however, is that it seems to ignore the IF statement and put the post on every page. I'm afraid I'm new to conditional statements - any idea how I correctly finish this IF statement?

RE: Comments form on a page, not post

(OP)
Thank you. Problem sorted.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close