WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] problem with comments and navigation link (5 posts)

  1. the0101
    Member
    Posted 1 year ago #

    I am new to making my own theme. I am having problem when I go into a single post. I can make it either have the comment box appear or the post navigation bar appear. Is there a solution for them to both appear?

    The following is my single.php. Thank you very much for your help.

    <?php get_header(); ?>
    <?php
    $myqueryname = $wp_query;
    $wp_query = null;
    $wp_query = new WP_Query();
    $wp_query->query('showposts=1'.'&paged='.$paged);
    ?>

    <div id="content">

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

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

    <div class="post">
    <div class="post-date"><span class="post-month"><?php the_time('M') ?></span> <span class="post-day"><?php the_time('j') ?></span></div>
    <div class="post-title">
    <h2><?php the_title(); ?></h2>
    <span class="post-cat"><?php the_category(', ') ?></span>
    <span class="post-comments"><?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?></span>
    </div>
    <div class="entry">
    <?php the_content('Read the rest of this entry »'); ?>

    <?php wp_link_pages(array('before' => '<p>Pages: ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
    </div>
    </div>

    <?php endwhile; ?>
    <?php wp_reset_query(); ?>
    <?php comments_template(); ?>

    <?php else : ?>

    <h2>Not Found</h2>
    <p>Sorry, but you are looking for something that isn't here.</p>

    <?php endif; ?>
    <div class="navigation">
    <span class="previous-entries"><?php next_posts_link('Older Entries') ?></span>
    <span class="next-entries"><?php previous_posts_link('Newer Entries') ?></span>
    </div>

    <?php $wp_query = null; $wp_query = $myqueryname;?>

    </div>
    <!--/content -->

    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

  2. alchymyth
    Forum Moderator
    Posted 1 year ago #

    use next_post_link() and previous_post_link()
    http://codex.wordpress.org/Function_Reference/next_post_link

    review
    http://codex.wordpress.org/Theme_Development

    remove this section:

    <?php
    $myqueryname = $wp_query;
    $wp_query = null;
    $wp_query = new WP_Query();
    $wp_query->query('showposts=1'.'&paged='.$paged);
    ?>
  3. the0101
    Member
    Posted 1 year ago #

    Hi alchymyth,

    Thank you for the reply. I already removed that section and removed <?php wp_reset_query(); ?>.

    And I changed the following.

    <div class="navigation">
    <span class="previous-entries"><?php next_posts_link() ?></span>
    <span class="next-entries"><?php previous_posts_link() ?></span>
    </div>

    But I still don't see the navigation links. The comments box are there.

    Thanks.

  4. alchymyth
    Forum Moderator
    Posted 1 year ago #

    the suggested code is 'next_post_link()' without the s after post; see the linked Codex chapter

  5. the0101
    Member
    Posted 1 year ago #

    Thank you very much for your help. It works now. :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.