WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Where is this coming from? (15 posts)

  1. ransom1337
    Member
    Posted 3 years ago #

    Hi,

    I'm using Firebug to take a closer look at my single post page. The layout is messed up and I can tell it's because a </div> appears where it shouldn't be.

    I'm editing comments.php for this part, as it's where I can see the code where the issue seems to be coming from:

    <?php if ( have_comments() ) : ?>
    
    	<ol class="commentlist">
    	<?php wp_list_comments(); ?>
    	</ol>
    
     <?php else : // this is displayed if there are no comments so far ?>
    
    	<?php if ( comments_open() ) : ?>
    		<!-- 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 ( comments_open() ) : ?>
    
    <div class="blog_post_wrap">
    
    <h3><?php comment_form_title( 'Leave a Reply', 'Leave a Reply to %s' ); ?></h3>

    Yet the HTML on Firebug is showing:

    <ol class="commentlist">
    <div class="commenter_details"></div>
    <div class="commenter_post"></div>
    <div class="reply"></div>
    </ol>
    
    </div>
    
    <div id="respond">
    <h3>Leave a reply</h3>
    // etc...

    Where is that </div> in the middle coming from? And now I mention it, where's that <div class="reply"></div> come from? I can't see them anywhere on comments.php but I'm guessing they're hidden within one of those php calls there. Which files should I look at to take a closer look at them?

    Thanks.

  2. esmi
    Theme Diva & Forum Moderator
    Posted 3 years ago #

    They're coming from further down - in the comment form section.

  3. ransom1337
    Member
    Posted 3 years ago #

    I did a Find for the word "reply" in comments.php and it doesn't show up any further down than at:

    <div class="cancel-comment-reply">
    	<small><?php cancel_comment_reply_link(); ?></small>
    </div>

    Which is just a few lines of code above the form.
    Have I missed it again?

    Thanks for all your help today esmi.

  4. esmi
    Theme Diva & Forum Moderator
    Posted 3 years ago #

    What are you using the generate the comment form itself?

  5. ransom1337
    Member
    Posted 3 years ago #

    <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">

    Just the default.

  6. esmi
    Theme Diva & Forum Moderator
    Posted 3 years ago #

    That's just the start of the form. Where's the rest of it?

  7. ransom1337
    Member
    Posted 3 years ago #

    <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
    
    <?php if ( is_user_logged_in() ) : ?>
    
    <p>Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="Log out of this account">Log out &raquo;</a></p>
    
    <?php else : ?>
    
    <p><input type="text" name="author" id="author" value="<?php echo esc_attr($comment_author); ?>" size="22" tabindex="1" <?php if ($req) echo "aria-required='true'"; ?> />
    <label for="author"><small>Name <?php if ($req) echo "(required)"; ?></small></label></p>
    
    <p><input type="text" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" size="22" tabindex="2" <?php if ($req) echo "aria-required='true'"; ?> />
    <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 esc_attr($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: <code><?php echo allowed_tags(); ?></code></small></p>-->
    
    <p><textarea name="comment" id="comment" cols="58" rows="10" tabindex="4"></textarea></p>
    
    <p><input name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" />
    <?php comment_id_fields(); ?>
    </p>
    <?php do_action('comment_form', $post->ID); ?>
    
    </form>
    
    <?php endif; // If registration required and not logged in ?>
    </div>
    
    <?php endif; // if you delete this the sky will fall on your head ?>
  8. esmi
    Theme Diva & Forum Moderator
    Posted 3 years ago #

    I think it would be a lot easier if you dropped a copy of the complete comments.php file into the WordPress pastebin and post the pastebin url here.

    A link to one of your single posts on your site might also help.

  9. ransom1337
    Member
    Posted 3 years ago #

  10. esmi
    Theme Diva & Forum Moderator
    Posted 3 years ago #

    Pretty much all of your issues appear to centre around the comment list display/markup. But the code in the pastebin doesn't match the output...

    Either that's not the right comment template for that page/theme. Or you're using a comment plugin that is interfering. Or you've hacked the core script for wp_list_comments(). Or modified wp_list_comments() output (possibly using a filter?) in your theme.

    The script in the pastebin uses:

    <ol class="commentlist">
    <?php wp_list_comments(); ?>
    </ol>

    Default use. No custom callback.

    Meanwhile the source of from the relevant part of your single post page is:

    <ol class="commentlist">
    <div class="blog_post_wrap">
    <div class="blog_post_left">

    That's not the markup that is generated by <?php wp_list_comments(); ?>. Added to which, it's all of the this "non-standard" markup that's causing your problems.

  11. ransom1337
    Member
    Posted 3 years ago #

    Ah yes, I have been fiddling around with some of the php files in the wp-includes folder, such as comment-template.php, I didn't realise I wasn't supposed to touch them. What's the proper place to edit the look/style/layout of the comments then? Cause I could only find them in that folder, really.

  12. ransom1337
    Member
    Posted 3 years ago #

    Update: I erased the wp-includes folder then re-uploaded the original files and it seems to have fixed the div issue. So thanks for that, esmi.

    How do I go about changing what information is shown and how it's laid out/styled in the comments, please? For example, I would like the avatar/username/date to be in a separate div to the comment itself.

    Thanks again for your patience and help.

  13. ransom1337
    Member
    Posted 3 years ago #

    From looking around I'm figuring that I have to write a custom function in functions.php and then call it in comments.php with:

    <ol class="commentlist">
    	<?php wp_list_comments('type=comment&callback=function_name'); ?>
    	</ol>

    Is that the right thing to do?

  14. ransom1337
    Member
    Posted 3 years ago #

    Sorry for my fourth post in a row, just wanted to confirm for any that may be experiencing the same difficulties as me that what I mentioned in the previous post is the correct way to do it. There's a pretty good guideline on how to do it here:

    http://www.problogdesign.com/wordpress/advanced-wordpress-comment-styles-and-tricks/

  15. esmi
    Theme Diva & Forum Moderator
    Posted 3 years ago #

    Sorry - I've been away from the office for a while...

    A custom callback for wp_list_comments is exactly what I would have suggested. Generally speaking, it's a Bad Idea(tm) to start editing core files unless you're:

    1) really, really, experienced
    2) are willing to repeat the core hacks each time you upgrade.

    Glad to hear that you've got it sorted.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.