Support » Fixing WordPress » <!–more–> tag not working in category display

  • In both WP 2.2 and WP 2.2.1, post are shown in full despite the use of <!–more–> tags.

    It happens on a category page, where I call the posts this way: get_posts( “category=2&numberposts=5” )

Viewing 7 replies - 1 through 7 (of 7 total)
  • Are you then using the_content to display the post content?

    Yep, here is the code I use:

    <?php $posts = get_posts( "category=2&numberposts=5" ); ?>
    <?php if( $posts ) : ?>
    <?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
    <div class="meta"><h1 class="title">
    <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>">
    <?php the_title(); ?></a></h1></div>
    <div class="content">
    <?php the_content(); ?></div>
    <?php endforeach; ?>
    <?php endif; ?>

    Used your code with the WordPress Default 1.6 theme , in a file called category.php, and it worked, meaning it displayed the text up to <!--more--> and presented a link to view the whole article.

    Using that same code on a Page template resulted in the whole post being displayed, meaning the <!--more--> quicktag was ingored. This is the expected behaviour.

    Weird, since I did use it in a Category-template:
    Named a file ‘category-2.php’ and used the above code in it.

    I think it must be conflicting with something else in the file, since when I put it in en empty page (like you did) it works fine…

    I’ll let you know what I find, thanks so far

    Ok, I found the cause, but not the solution yet:

    On the same category-page I was showing the content of a page by using this code:

    <?php query_posts( 'page_id=49' ); ?>
    <?php while (have_posts()) : the_post(); ?>
    <div class="post" id="post-<?php the_ID(); ?>">
    <div class="entry">
    <?php the_content(); ?>
    <?php endwhile; ?>

    If I remove this, the <!– more –> tags work fine. Now my problem is how to show the content of that page without disturbing the category display?

    Got it!

    This did what I was looking for:

    $my_query = new WP_Query('page_id=49');
    while ($my_query->have_posts()) : $my_query->the_post();
    $do_not_duplicate = $post->ID;
    <?php the_content(); ?>
    <?php endwhile; ?>

    I’m having the same problem, but not sure if that solution works for me – or at least haven’t been able to wrap my head around it enough to get it to work.

    I’m calling posts like so

    <?php> query_posts("cat=1"); ?>

    on a page template. The more link doesn’t work.

    “this is the expected behaviour”

    Is there a way around this? Thanks.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘<!–more–> tag not working in category display’ is closed to new replies.