• I have a problem with a template called “Wedding rose” – when you submit comments to it no html seems to get included. If you view the source for the page the comment is formatted with every hard line break/paragraph intact, but as there are no HTML tags everything will be displayed as one block of text.

    I know the problem has to be with the template, comments are formatted just fine if I switch to the default template (new comments that is, comments submitted through the wedding rose template are still one block of text).

    Does this mean the error is in the CSS or in Comments.php?

    This is the comments section of the CSS:

    /* The Comments */
    
    #commentform p {
    	font-family: 'Lucida Grande', Verdana, Arial, Sans-Serif;
    	}
    
    .commentmetadata {
    	font-weight: normal;
    	}
    
    .comments {
    	}
    .comments form {
    	}
    .comments textarea {
    	width:90%;
    	height:156px;
    	background:#dad1c2;
    	border:1px solid #e3e3e3;
    	color:#666666;
    	padding:10px;
    	overflow:auto;
    	font-family:Arial, Helvetica, sans-serif;
    	font-size:14px;
    	}
    #commentform {
    	padding-left:23px;
    	}
    #commentform input {
    	background:#dad1c2;
    	color:#666666;
    	padding-left:10px;
    	}
    .comments input#submit {
    	padding:0;
    	width:95px;
    	height:30px;
    	}
    .comments h2 {
    	font-size:19px;
    	line-height:30px;
    	margin:24px 0 0 23px;
    	padding:0;
    	font-weight:normal;
    	}
    .comments ol li p {
    	padding:0;
    	margin:10px 0;
    	color:#666666;
    	}

    And this is Comments.php:

    <?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. -->
    
    <div class="comments" id="comments">
    
    <?php if ($comments) : ?>
    	<ol>
    
    	<?php foreach ($comments as $comment) : ?>
    
    		<li class="<?php echo $oddcomment; ?>" id="comment-<?php comment_ID() ?>">
    			<strong><?php comment_author_link() ?></strong> Said,
    			<?php if ($comment->comment_approved == '0') : ?>
    			<p><em>Your comment is awaiting moderation.</em></p>
    			<?php endif; ?>
    
    			<?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; ?>
    
    <?php if ('open' == $post->comment_status) : ?>
    
    <h2 id="respond">Add A Comment</h2>
    
    <?php if ( get_option('comment_registration') && !$user_ID ) : ?>
    <p>You must be <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php the_permalink(); ?>">logged in</a> to post a comment.</p>
    <?php else : ?>
    
    <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
    <?php echo frev_get_rating_fields(IPAddress); ?>
    
    <?php if ( $user_ID ) : ?>
    
    <p>Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="Log out of this account">Logout &raquo;</a></p>
    
    <?php else : ?>
    
    <p><input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="22" tabindex="1" /> <label for="author"><small>Name <?php if ($req) echo "(required)"; ?></small></label></p>
    
    <p><input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="22" tabindex="2" /> <label for="email"><small>Mail (will not be published) <?php if ($req) echo "(required)"; ?></small></label></p>
    
    <p><input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="22" tabindex="3" /> <label for="url"><small>Website</small></label></p>
    
    <?php endif; ?>
    
    <!--<p><small><strong>XHTML:</strong> You can use these tags: <?php echo allowed_tags(); ?></small></p>-->
    
    <p><textarea name="comment" id="comment" style="width:90%; height:150px" tabindex="4"></textarea></p>
    
    <p><input name="submit" type="image" src="<?php bloginfo('stylesheet_directory'); ?>/images/post.jpg" id="submit" tabindex="5" />
    <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
    </p>
    <?php do_action('comment_form', $post->ID); ?>
    
    </form>
    
    <?php endif; // If registration required and not logged in ?>
    
    <?php endif; // if you delete this the sky will fall on your head ?>
    
    </div>
Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter bhakans

    (@bhakans)

    Bump.

    Does no one have an answer to this. I imagine it should be easily solved by someone better at WordPress coding than me?

    I have the same issue noted above. There is something about this line:
    <?php comment_text() ?>
    It encloses each comment line in paragraph tags but it doesn’t add the so everything looks scrunched up.

    I have tried str_replace to fix this, but it remains unaffected:
    <?php echo str_replace("</p>","</p><br />", comment_text()); ?>
    I am all out ideas and I am not sure how to fix this either. I have tried other themes and they include the line breaks.

    I hope this helps explain what the issue is.

    try

    <?php echo get_comment_text(); // no default filters ?>

    Hello,

    I tried

    <?php echo get_comment_text(); // no default filters ?>

    and it removed all of the paragraph tags, removing all remaining linebreaks, making everything look like a giant paragraph no matter how many times the user added a line break for the comments.

    However, I modified your above line of code, which did change all newline characters to tags, which did fix my problem:

    <?php echo str_replace("\n","<br />",get_comment_text()); ?>

    So, basically it got rid of the paragraph tags but it replaces the newlines "\n" with <br />, which has the same output. It still has the same problem if I change get_comment_text() to comment_text(). The only downside to get_comment_text() is that it doesn’t convert web urls in comments to clickable hyperlinks, but this is not an issue for me. I don’t know if it truly follows proper HTML-etiquette, but it’s a nice quickfix for now.

    What about wrapping <?php comment_text() ?> in its own class?
    i.e. class=”comment_text”

    I’m sorry. I don’t know anything about wrapping classes. How would it be done for comment_text?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Comments display as one block of text’ is closed to new replies.