Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have loop, wich create news feed, it looks like:

(part of news template)

News.php

        <div id="content">
        <div class="scrollArea">
            <?php query_posts('category_name=News');?>
            <?php  if (have_posts()) : while (have_posts()) : the_post(); ?>
                    <div class="news_block">
                        <p class="news_title"><?php the_title(); ?></p>
                        <p class="news_date"><?php the_time('F jS, Y'); ?></p>
                        <p class="news_text"><?php the_content(); ?></p>
                        <a href="<?php comments_link(); ?>">Comments to this post     (<?php comments_number('0', 'One Response', '%' ); ?>) </a>
                    </div>
            <?php endwhile;?>
            <?php endif; ?>        
        </div>

        </div>
  <div class="news_right"></div>
 </div> 
<?php
    get_footer(); 
?>   

Comments.php

<?php
/**
 * @package WordPress
 * @subpackage Starkers HTML5
 */
// Do not delete these lines
        if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' ==         basename($_SERVER['SCRIPT_FILENAME']))
        die ('Please do not load this page directly. Thanks!');

    if ( post_password_required() ) { ?>
        <p class="alert">This post is password protected. Enter the password to    view comments.</p>
        <?php
        return;
    }
?>

    <!-- You can start editing here. --> <--edit from here-->
<?php get_header();
get_template_part('nav');  ?>
<div id="content">
        <div class="scrollArea">
   <--end editing heret-->

<?php if ( have_comments() ) : ?>

    <h3 id="comments"><?php comments_number('No Responses', 'One Response', '% Responses' );?> to &#8220;<?php the_title(); ?>&#8221;</h3>

    <?php previous_comments_link() ?> <?php next_comments_link() ?>

    <!-- View functions.php for comment markup -->
    <?php wp_list_comments('callback=html5_comment&end-callback=close_comment'); ?>

    <?php previous_comments_link() ?> <?php next_comments_link() ?>

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

<h3 id="respond"><?php comment_form_title( 'Leave a Reply', 'Leave a Reply to %s' ); ?></h3>

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

<?php if ( get_option('comment_registration') && !is_user_logged_in() ) : ?>
<p>You must be <a href="<?php echo wp_login_url( get_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 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" <?php if ($req) echo "required"; ?> />
    <label for="author">Name <?php if ($req) echo "(required)"; ?></label></p>

    <p><input type="email" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" size="22" <?php if ($req) echo "required"; ?> />
    <label for="email">Mail (will not be published) <?php if ($req) echo "(required)"; ?></label></p>

    <p><input type="url" name="url" id="url" value="<?php echo esc_attr($comment_author_url); ?>" size="22" />
    <label for="url">Website</label></p>

    <?php endif; ?>

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

    <textarea name="comment" id="comment" cols="50" rows="10" required></textarea>

    <button type="submit" name="submit" id="send">Submit Comment</button>

    <?php comment_id_fields(); ?>

    <?php do_action('comment_form', $post->ID); ?>

</form>

<?php endif; // If registration required and not logged in ?>

 </div> 
    <?php get_footer(); ?>

Link to comments works fine, comments appear inside of container "content" and looks good. but previous, current and next posts appear outside of container "content", after header and before all other content. I made changes only in news page template and my_theme/comments.php file. (tags "edit from here" and "end editing here") Which files I need to modify else? What is the problem could be?

share|improve this question
    
"previous, current and next posts": Are you talking about comments or posts? Links to them or the actual content? Can you edit your question to include the HTML output you get, and the template code that (you think) generates it? Include the name of the template files. (Use @Jan when you reply to me in a comment and I get a notification) –  Jan Fabry Apr 8 '11 at 9:49
    
Why are you calling get_footer() inside of comments.php? Also, where are you calling comments_template() inside of "news.php"? –  Chip Bennett Apr 8 '11 at 18:01

2 Answers 2

Use comment_form() not a self made code. See the answers to question 15179 for a working example of a comments.php.

share|improve this answer

http://codex.wordpress.org/Next_and_Previous_Links

Please read through WordPress Codex, it does help.

share|improve this answer
    
@Jan: About posts, when I open the page with comments for last post, current, prev posts and post from another category (full text of posts) appear after header and before main content, this posts text are links to list of comments of those posts ! When I open the page with comments not for the last post, prev, current and next posts appear after header and before main content, this text of posts are also links to list of comments of those posts! Sorry for inaccuracy before! –  tokmak Apr 8 '11 at 17:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.