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 “<?php the_title(); ?>”</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 »</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?
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 “<?php the_title(); ?>”</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 »</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 edited Apr 26, 2011 at 3:19 Chris_O 20.6k5 gold badges62 silver badges96 bronze badges asked Apr 7, 2011 at 23:13 tokmaktokmak 1862 silver badges9 bronze badges 2 |2 Answers
Reset to default 1Use comment_form() not a self made code. See the answers to question 15179 for a working example of a comments.php.
http://codex.wordpress/Next_and_Previous_Links
Please read through WordPress Codex, it does help.
@Jan
when you reply to me in a comment and I get a notification) – Jan Fabry Commented Apr 8, 2011 at 9:49get_footer()
inside of comments.php? Also, where are you callingcomments_template()
inside of "news.php"? – Chip Bennett Commented Apr 8, 2011 at 18:01