WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] display the excerpt of a recent catergory post (6 posts)

  1. ethicus
    Member
    Posted 4 years ago #

    Hi there I´ve managed to make a page that loads recent post of different categories. code looks like this:

    <?php $recent = new WP_Query("cat=8&showposts=1"); while($recent->have_posts()) : $recent->the_post();?>
                 <h1><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1>
                 <?php the_content('Read more'); ?>
                <?php endwhile; ?>

    The post with cat id 8 has a more tag in it, but i don't see the read more link in the output can someone help me out on this one?

  2. MichaelH
    Member
    Posted 4 years ago #

    Try this before the_content

    <?php global $more; $more = 0; ?>

  3. ethicus
    Member
    Posted 4 years ago #

    <?php $recent = new WP_Query("cat=8&showposts=1"); while($recent->have_posts()) : $recent->the_post();?>
                 <h1><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1>
    <?php global $more; $more = 0; ?>
                 <?php the_content('Read more'); ?>
                <?php endwhile; ?>

    this don't work...

  4. MichaelH
    Member
    Posted 4 years ago #

    Hmm; what about:
    global $wp_query;
    $wp_query->in_the_loop = true;

  5. ethicus
    Member
    Posted 4 years ago #

    Nope that wont do it neither :o(

  6. ethicus
    Member
    Posted 4 years ago #

    I'm sorry i've put in a post that doesn't have the more tag in it DUH!
    Could you tell me what the extra code does?

    THIS CODE WORKS!

    <?php $recent = new WP_Query("cat=5&showposts=1"); while($recent->have_posts()) : $recent->the_post();?>
                 <h1><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1>
    			<?php global $more; $more = 0; ?>
                 <?php the_content('Read More..'); ?>
                <?php endwhile; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic