WordPress.org

Ready to get started?Download WordPress

Forums

Using single.php for different comment page (19 posts)

  1. Daisyhead
    Member
    Posted 8 years ago #

    I am in the process of designing a new website for a friend and want the comments page to work differently than the index page. An example would be here, http://www.morningsmiles.com/. I want the comment page to look like the main index page where the entry is listed above but I want the actual comment form and the comments to be listed below in the pink portion of the page.

    Are you still with me?

    I'm assuming I could do this by using the single.php file and somehow calling that into use when people click on the comments link on the main index page, but I'm unsure how this would work. If anyone could give some guidance, I would GREATLY appreciate it.

  2. Daisyhead
    Member
    Posted 8 years ago #

    Okay, I think I figured this out, somewhat. The only problem I'm having is that the actual comments aren't showing up on my individual pages.

    Example: http://www.morningsmiles.com/2006/06/12/morning-smiles-is-coming-soon/

    Here's my code:

    <?php get_header(); ?>

    <div id="container">

    <div id="top">

    <div id="blog">

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    <h1 id="post-<?php the_ID(); ?>"><img src="http://morningsmiles.com/wp-content/themes/pinkcosmos/images/cosmo2.png"> " rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></h1>

    <div class="entrybody">
    <div class="pad">
    <?php the_content('<p class="serif">Read the rest of this entry »'); ?>

    </div> <!-- end PAD -->
    </div> <!-- end ENTRY BODY -->

    <div align="center"><?php previous_post('« %','','yes') ?> <?php next_post(' % »','','yes') ?></div>

    <?php endwhile; else: ?>

    <?php _e('Sorry, no posts matched your criteria.'); ?>

    <?php endif; ?>

    </div> <!-- end BLOG -->

    <div id="image"></div> <!-- end IMAGE -->
    </div> <!-- end TOP -->

    <br clear="all">

    <div id="middle">

    <div id="column1">
    <h2><img src="http://morningsmiles.com/wp-content/themes/pinkcosmos/images/bullet.gif"> Leave a Comment <img src="http://morningsmiles.com/wp-content/themes/pinkcosmos/images/bullet.gif"> </h2>

    <?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.

    <?php
    return;
    }
    }

    /* This variable is for alternating comment background */
    $oddcomment = 'alt';
    ?>

    <?php if ('open' == $post->comment_status) : ?>

    <?php if ( get_option('comment_registration') && !$user_ID ) : ?>
    You must be /wp-login.php?redirect_to=<?php the_permalink(); ?>">logged in to post a comment.
    <?php else : ?>

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

    <?php if ( $user_ID ) : ?>

    Logged in as /wp-admin/profile.php"><?php echo $user_identity; ?>. /wp-login.php?action=logout" title="Log out of this account">Logout »

    <?php else : ?>

    <input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="35" tabindex="1" />
    <label for="author"><small>Name <?php if ($req) echo "(required)"; ?></small></label>

    <input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="35" tabindex="2" />
    <label for="email"><small>Mail (will not be published) <?php if ($req) echo "(required)"; ?></small></label>

    <input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="35" tabindex="3" />
    <label for="url"><small>Website</small></label>

    <?php endif; ?>

    <!--<small>XHTML: You can use these tags: <?php echo allowed_tags(); ?></small>-->

    <textarea name="comment" id="comment" cols="60" rows="10" tabindex="4"></textarea>

    <input name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" />
    <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />

    <?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>

    <div id="column2">
     
    </div>

    <div id="column3">
    <h2><img src="http://morningsmiles.com/wp-content/themes/pinkcosmos/images/bullet.gif"> Comments <img src="http://morningsmiles.com/wp-content/themes/pinkcosmos/images/bullet.gif"> </h2>
    <?php if ($comments) : ?>
    <h3 id="comments"><?php comments_number('No Responses', 'One Response', '% Responses' );?> to “<?php the_title(); ?>”</h3>

    <?php foreach ($comments as $comment) : ?>

    <cite><?php comment_author_link() ?></cite> Says:
    <?php if ($comment->comment_approved == '0') : ?>
    Your comment is awaiting moderation.
    <?php endif; ?>

    <small class="commentmetadata">" title=""><?php comment_date('F jS, Y') ?> at <?php comment_time() ?> <?php edit_comment_link('e','',''); ?></small>

    <?php comment_text() ?>

    <?php endforeach; /* end for each comment */ ?>

    <?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.

    <?php endif; ?>
    <?php endif; ?>
    </div>

    </div> <!-- end MIDDLE -->

    <div id="footer">

    <?php get_footer(); ?>

  3. Daisyhead
    Member
    Posted 8 years ago #

    Okay, since no one is biting, here's a simple version of what I'm trying to do. I am basically cutting and pasting from my wp-comments.php template and putting that code into my single.php page so I can customize where the comments form and comments are in my layout (code is above). The comment form is showing on my individual entry page, etc., but the actual comments aren't.

    I'd would really love some help on this issue. Thanks in advance!

  4. Daisyhead
    Member
    Posted 8 years ago #

    Anyone? =(

  5. moshu
    Member
    Posted 8 years ago #

    cutting and pasting from my wp-comments.php template and putting that code into my single.php

    You must be behind by ages - wp-comments.php used to be in WordPress 1.2.x, and no more since WP 1.5.

    You don't need to cut/paste anything.
    You have to call the comments.php into your single.php template file - inside the Loop. See how it is done in the Default.

  6. Daisyhead
    Member
    Posted 8 years ago #

    My bad. I typed the wrong file name. I *am* using the comments.php file with the latest version of WP. My problem is that when I leave the code in to call in the comments.php file, I can't customize where the comment form and actual comments lay in my layout. I thought I could get around this by taking the "pieces" of the comments.php file and placing them where I want them to be in my layout (single.php) but it doesn't work right. I am getting the comment form but the actual comments are not showing up.

    I copied and pasted the code from my single.php file above and was wondering if someone could take a look at it and see why the comments aren't showing up. I would REALLY appreciate it.

  7. moshu
    Member
    Posted 8 years ago #

    Don't hope. The code here is usually not readable (wondering why a mod didn't delete it ;) - use a pastebin service and post back the URI.

    On the other hand I don't understand this:
    customize where the comment form and actual comments lay in my layout
    It is always pure CSS.

  8. Daisyhead
    Member
    Posted 8 years ago #

    If you look at this link, http://www.morningsmiles.com/2006/06/13/movin-on-up/#comments you'll see that I have the comments form down in the pink section of the page. I want the actual comments themselves to show just to the right of the comment form, in the pink section below the actual blog entry.

    Every time I tried to call comments.php into the single.php page, the comment form and comments both showed wherever I placed the call. I don't want that.

    Here's a link to the single.php page,

    http://www.morningsmiles.com/singlephp.txt

    You can see the code to call the actual comments is under "column3" but yet the comments aren't showing. That's what I am needing help with.

    Thanks for your patience Moshu!

  9. Daisyhead
    Member
    Posted 8 years ago #

    PS - please don't pay any attention to my messy code. I'm in the process of designing a theme from scratch and I've yet to work out all the kinks. One problem I'm having is with the footer portion of the layout being fluid and moving down when the middle (or pink section) grows longer. I figure I can fix that AFTER I get the actual code issues fixed. :-)

  10. moshu
    Member
    Posted 8 years ago #

    OK, I just re-read your posts above. The comments are not showing up because you call the comments template (regardless it's an "include" call or the code copied over) after closing the WP Loop. So the engine doesn't know which comments to show: outside the Loop they are not associated with the post.

  11. Daisyhead
    Member
    Posted 8 years ago #

    Okay, I read up on the Loop in the Codex and moved:

    <?php endwhile; else: ?>
    <?php _e('Sorry, no posts matched your criteria.'); ?>
    <?php endif; ?>

    To the end of my file, after ALL of the comment code and still nothing. I will go back over it and see if I'm missing something. The updated code is now uploaded:

    morningsmiles.com/singlephp.txt

  12. Daisyhead
    Member
    Posted 8 years ago #

    Okay. The comments still aren't showing up after changing the placment of the end of the loop code. Suggestions?

  13. Daisyhead
    Member
    Posted 8 years ago #

    Ugh. I am at a loss as to what I'm doing wrong. I've gone back over my single.php file with a fine tooth come and cannot find why the comments aren't showing. I've adjusted the end of the loop to include all of the code relevant to the comments and still nothing...

  14. moshu
    Member
    Posted 8 years ago #

    Just for the sake of testing.
    If you delete the comments code from it and call the comments template in the usual manner does it work?

  15. Daisyhead
    Member
    Posted 8 years ago #

    Yep. It's just that the comment content (the comment form and actual comments) doesn't show up where I want it in the design.

  16. moshu
    Member
    Posted 8 years ago #

    Question. Is the comments.php file's code identical to what you are copy/pasting into the single?

    I still don't understand how comes it won't display where you want it - especially now that you know you have to have it inside the Loop.
    Are there any comment related plugins activated?

  17. Daisyhead
    Member
    Posted 8 years ago #

    Well, I tried editing the comments.php file so it does not contain the same stuff and I tried deleting it entirely. Should I try something different with that file?

  18. Daisyhead
    Member
    Posted 8 years ago #

    I guess I'll go poke around the forums to see if I can find an answer to this. The comments still aren't showing up and I'm really at a loss.

  19. Daisyhead
    Member
    Posted 8 years ago #

    Hm. If I uncomment the comment popup code, I get the pop up window and the comments are showing up, yet if I comment that back out, I still get nothing on my individual entry page...

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags