• Resolved Jelly92

    (@jelly92)


    I’ve created two themes and both have the same problem. When trying to validate my HTML, I get the error ‘Duplicate ID comment_post_ID.’

    I’ve looked at the source code and tracked it down to this line:

    <input type='hidden' name='comment_post_ID' value='14' id='comment_post_ID' />

    Which appears twice. This is WordPress-generated code, so I’m struggling to understand why it’s happening. It has to be something I’ve done to my comments.php file, right? So if anyone wants to have a look, it’s here:

    <?php if(!empty($_SERVER[‘SCRIPT_FILENAME’]) && ‘comments.php’ == basename($_SERVER[‘SCRIPT_FILENAME’])) :
        die( 'This page cannot be viewed independently.' );
        endif;
        if(!empty($post->post_password)) : if($_COOKIE[‘wp-postpass_’ . COOKIEHASH] != $post->post_password) :
        endif;
        endif; ?>
    
    	<?php
    	if ( post_password_required() ) {
    	echo 'This post is password protected. Enter the password to view comments.';
    	return;
    	}
    	?>
    	<?php if ( have_comments() ) : ?>
    		<div class="respond">
    			<div id="comments">
    				<h3>Comments:</h3>
    				<ol><?php wp_list_comments(); ?></ol>
    			<div class="pages">
    				<?php paginate_comments_links(); ?>
    			</div>
    		<?php endif; ?>
    
    		<?php comment_id_fields();	?>
    		<?php comment_form(); ?>
    		</div>
    	</div>

    Thank you so much for any help 🙂

    Edit – Right, so taking out this line makes it work:

    <?php comment_id_fields(); ?>

    I thought that was necessary… could someone let me know if taking that out is going to cause problems?

The topic ‘Comment_post_ID line appearing twice’ is closed to new replies.