WordPress.org

Ready to get started?Download WordPress

Forums

Comments and More links not showing up. (4 posts)

  1. SavoryMedia
    Member
    Posted 8 years ago #

    Ohhhhhhkiedokie.

    I went through the Codex and found the example of a list of posts where the first post is shown whole and the following ones are in a list format. (http://codex.wordpress.org/The_Loop - The "Multiple Loops in Action" section near the bottom.)

    On my front page, I put the code in and styled it as follows.

    <?php $my_query = new WP_Query('category_name=news&showposts=1'); while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID;?>
    <h2 class="posttitle"><span class="timedate"><?php the_time('F jS, Y') ?> &bull; <?php the_time('g:i a') ?> &bull; <?php comments_popup_link('(0)', '(1)', '(%)', '', 'disabled'); ?></span><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    <div class="postbody"><?php the_content('Read more &raquo;'); ?></div>
    <?php endwhile; ?>
    <!-- Space for other stuff -->
    <?php query_posts('category_name=news&showposts=9'); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts); ?>
    <h2 class="posttitle2"><span class="timedate"><?php the_time('F jS, Y') ?> &bull; <?php the_time('g:i a') ?> &bull; <?php comments_popup_link('(0)', '(1)', '(%)', '', 'disabled'); ?></span><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    <?php endwhile; endif; ?>

    I had to add the 2nd "query_posts" argument because the 2nd loop was pulling in pages as well as regular blog posts.

    Now everything works fine except, in the first post (the full one), the comments link won't appear and using <!--more--> in the post body doesn't work. The whole post is shown no matter what. (The comment link shows up fine in the 2nd loop.)

    My question is: what do I need to change in the query to make those links show up? I'm completely lost and any help would be greatly appreciated.

    Thanks in advance.

  2. Kafkaesqui

    Posted 8 years ago #

    Just covered this issue. See this thread (mainly this post):

    http://wordpress.org/support/topic/67173#post-355528

  3. SavoryMedia
    Member
    Posted 8 years ago #

    Kafka,

    Muchas gracias for the help! I had to hack the original query all up, but I got it to work with your $more = 0 code.

    So other people can see a working example, I'm including the code:

    <?php query_posts('category_name=news&showposts=1'); ?>
    <?php $more = 0; ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); $do_not_duplicate = $post->ID;?><?php $more = 0; ?>
    <h2 class="posttitle"><span class="timedate"><?php the_time('F jS, Y') ?> &bull; <?php the_time('g:i a') ?> &bull; <?php comments_popup_link('(0)', '(1)', '(%)', '', 'disabled'); ?></span><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    <div class="postbody"><?php the_content('Read more &raquo;'); ?></div>
    <?php endwhile; ?>
    <!-- Space for other stuff -->
    <?php query_posts('category_name=news&showposts=9'); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts); ?>
    <h2 class="posttitle2"><span class="timedate"><?php the_time('F jS, Y') ?> &bull; <?php the_time('g:i a') ?> &bull; <?php comments_popup_link('(0)', '(1)', '(%)', '', 'disabled'); ?></span><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    <?php endwhile; endif; ?>
    <?php endif; ?>

  4. SavoryMedia
    Member
    Posted 8 years ago #

    WHOOPS! Remove that second <?php $more = 0; ?> to clean up the code a little (my bad) and it still works fine.

    Thanks again, Kafka!

Topic Closed

This topic has been closed to new replies.

About this Topic